Files
mesh-controller/cmd/mesh-controller/bus_runs_test.go
T
jschoubben 565de8c46a Read what a bus machine runs from its have, not from a send kept (issue 1945, B6)
No send is kept any more (ADR 0539 clause 9), so SentBuilds has no last caller and B8 can delete it.
2026-10-24 17:24:51 +02:00

30 lines
1.1 KiB
Go

package main
import (
"context"
"testing"
)
// 1945 (dev-r6-controller's B8 follows it): what a bus machine runs is read from its have, not from a send kept, so a
// machine whose have names the build the mesh holds is not moved by a bus upgrade, and one whose have names an older
// build is.
func TestABusMachineRunsWhatItsHaveNames(t *testing.T) {
was := busRuns
t.Cleanup(func() { busRuns = was })
busRuns = func(_ context.Context, node, _ string) (string, bool, error) {
return map[string]string{"novox": "src2:new", "ace": "src2:old"}[node], node != "g14", nil
}
b := busPending{module: "nats", to: "c-new", from: map[string]string{}, same: map[string]bool{}}
commitOf := map[string]string{"src2:new": "c-new", "src2:old": "c-old"}
for _, n := range []string{"novox", "ace", "g14"} {
fp, known, _ := busRuns(context.Background(), n, "nats")
if c, ok := commitOf[fp]; known && ok {
b.from[n] = c
}
}
if b.moves("novox") || !b.moves("ace") || !b.moves("g14") {
t.Errorf("novox moves %v (runs the new build), ace %v (an older one), g14 %v (says none)", b.moves("novox"),
b.moves("ace"), b.moves("g14"))
}
}