You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// These cases all exercise the early-return branch of Setup — where
219
+
// e.network is already non-empty, either because NewEngineFromFlags
220
+
// populated it from --crossplane-docker-network or because a prior Setup
221
+
// call on the same engine stored its created network there. The branch
222
+
// must annotate the supplied functions so their containers join the
223
+
// network, never create a second network, and always return a no-op
224
+
// cleanup. The create-new-network branch is not covered here because it
225
+
// depends on a live Docker daemon; the broader render command tests
226
+
// exercise it integration-style.
227
+
//
228
+
// The MultiBatchAnnotatesAdditionalFunctions case simulates the
229
+
// in-process multi-composition use case from crossplane/cli#96: a
230
+
// downstream tool (crossplane-diff) calls Setup once per Composition it
231
+
// encounters. Pre-seeding e.network stands in for the prior Setup call
232
+
// that would have created the network, keeping the test hermetic.
233
+
constpresetNetwork="preset-net"
234
+
235
+
// batch holds a single Setup invocation: the fns to pass in and the
236
+
// expected fn state after Setup returns. Multi-call cases provide more
237
+
// than one batch; the runner invokes Setup once per batch in order.
238
+
typebatchstruct {
239
+
fns []pkgv1.Function
240
+
wantFns []pkgv1.Function
241
+
}
242
+
243
+
cases:=map[string]struct {
244
+
reasonstring
245
+
engine*dockerRenderEngine
246
+
batches []batch
247
+
}{
248
+
"AnnotatesFunctionsWhenNetworkPreset": {
249
+
reason: "When e.network is set, Setup must inject the network annotation on every fn that does not already carry one, so that crossplane-diff-style multi-batch callers can re-Setup to add new fns to the same network.",
reason: "If a fn already carries a runtime-docker-network annotation, Setup must not overwrite it. This preserves the don't-overwrite contract from PR #65 for users who pin their fns to a specific network.",
reason: "Two consecutive Setup calls on the same engine — the crossplane/cli#96 in-process multi-composition pattern — must annotate every batch with the same network. Each call returns a no-op cleanup that is safe to defer in LIFO order.",
0 commit comments