//go:build integration package main import ( "testing" "git.novox.be/novox/mesh-sdk/go/compose" ) // 1382/AC5: composing every node of one operation builds the Input once; without an operation's cache, once for each. func TestComposingEveryNodeOfAnOperationBuildsTheInputOnce(t *testing.T) { open, _ := aMeshWithSecrets(t) built := 0 was := composeInputBuilt composeInputBuilt = func() { built++ } t.Cleanup(func() { composeInputBuilt = was }) ctx := withInputCache(t.Context()) nodes, err := open.inventory.Nodes(ctx) if err != nil { t.Fatal(err) } for _, n := range nodes { if _, _, err := resolveNode(ctx, open, n.Name); err != nil && !unresolvable(err) { t.Fatal(err) } if _, _, err := composeQuestion(ctx, open, n.Name, compose.Reading, false); err != nil && !unresolvable(err) { t.Fatal(err) } } if _, err := generatorsOf(ctx, open); err != nil { t.Fatal(err) } if built != 1 { t.Fatalf("an operation over %d node(s) built the Input %d time(s)", len(nodes), built) } built = 0 if _, _, err := resolveNode(t.Context(), open, nodes[0].Name); err != nil && !unresolvable(err) { t.Fatal(err) } if built != 1 { t.Fatalf("a composition with no cache built the Input %d time(s)", built) } }