diff --git a/internal/agent/agent_test.go b/internal/agent/agent_test.go index 87a4a2b..082a3fe 100644 --- a/internal/agent/agent_test.go +++ b/internal/agent/agent_test.go @@ -1605,25 +1605,21 @@ func TestTheNodesOwnCompositionIsAppliedWhenItDiffersAndARecordMoveWaitsForAYes( eventually(t, "the wait for the composer was not said", func() bool { return saidCount() == 1 }) // Settled again by another want's change, it is neither said nor told again. other, oraw, _ := unsigned("ghost", fpOf("8"), file("ghost", "x", "1")) - settledGhost := func() (n int) { - b.mu.Lock() - defer b.mu.Unlock() - for _, m := range b.settled { - if m == "ghost" { - n++ - } - } - return n - } - settledBefore := settledGhost() b.comps.put(other, oraw) - eventually(t, "ghost was not settled again", func() bool { return settledGhost() > settledBefore }) - eventually(t, "the composer was not told", func() bool { toldMu.Lock(); defer toldMu.Unlock(); return len(told) == 1 }) + eventually(t, "ghost's other composition was not taken", func() bool { + b.ag.mu.Lock() + defer b.ag.mu.Unlock() + _, ok := b.ag.comps[other] + return ok + }) + // What is settled after it: web's want moves on, so ghost's settle, queued before it, has run. + want("web", fp, "") + eventually(t, "the composer was not told once", func() bool { toldMu.Lock(); defer toldMu.Unlock(); return slices.Contains(told, "ghost@"+fpOf("9")) }) if _, err := b.ag.Composition(context.Background(), "ghost", "", false); err == nil || !strings.Contains(err.Error(), "waits for the composer: no manifest in the composer's picture") { t.Errorf("the composition read of ghost says %v, want why the composer made none", err) } toldMu.Lock() - if saidCount() != 1 || len(told) != 1 || told[0] != "ghost@"+fpOf("9") { + if n := slices.Index(told, "ghost@"+fpOf("9")); saidCount() != 1 || n < 0 || slices.Contains(told[n+1:], "ghost@"+fpOf("9")) { t.Errorf("said %d times, told %q; want once and ghost told once", saidCount(), told) } toldMu.Unlock()