A composition over the Input makes nothing; a send performs what it named (the pair credentials no row holds, the seats to pass, the ports and own secrets, the core credentials asked of the vault every send, the certificate), reads the stores again and composes again, and refuses a declaration that still stands in for a value anywhere in its body. A question (composeQuestion) never performs. The operation's Input is read once and kept in its context until a send changes what it read, per what the context keeps (recorded builds, the grants step, a settings walk). A core credential the vault did not answer for and no box is kept for refuses the send, where the controller sealed it itself (ADR 0396): the composition has no such fallback (reported). Callers switch in the next commits.
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
//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)
|
|
}
|
|
}
|