diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go index f4aaa5af..7a0ccf15 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionruns_test.go @@ -1,8 +1,10 @@ package main import ( + "context" "encoding/json" "fmt" + "maps" "os" "path/filepath" "slices" @@ -601,6 +603,30 @@ func TestACompositionRunsBoundTimesOwedProgress(t *testing.T) { if keys, _ := r.keysOf("main.3", "a"); !slices.Equal(keys, []string{runKeyOf("main.3", "n1"), runKeyOf("main.3", "n2")}) { t.Errorf("the runs of reader a: %v", keys) } + // A-470q: a reader with no `ended` says its first end under its ask's id; d, marked rerun, says its end again under + // `.`. + ids := make(chan [2]string, 3) + steps := &compositionSteps{node: "n1", now: func() time.Time { return now }, logf: t.Logf, + resume: func(context.Context, string, meshwants.StepRun) stepOutcome { + return stepOutcome{Outcome: meshwants.StepEndedOutcomePassed} + }, + say: func(_ string, body any, id string) error { + ids <- [2]string{body.(meshwants.StepEnded).ID, id} + return nil + }} + steps.takeUp(context.Background(), r) + got := map[string]string{} + for range 3 { + select { + case e := <-ids: + got[e[0]] = e[1] + case <-time.After(5 * time.Second): + t.Fatalf("the ends of the take-up: %v", got) + } + } + if want := map[string]string{"a": "a", "b": "b", "d": "d.run-n1"}; !maps.Equal(got, want) { + t.Errorf("the message ids of the take-up's ends: %v, want %v", got, want) + } }) }