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")) } }