diff --git a/modules/mesh-delivery-checker/internal/check/checker_test.go b/modules/mesh-delivery-checker/internal/check/checker_test.go index e644894b..e33901e1 100644 --- a/modules/mesh-delivery-checker/internal/check/checker_test.go +++ b/modules/mesh-delivery-checker/internal/check/checker_test.go @@ -3,6 +3,7 @@ package check import ( "context" "encoding/json" + "errors" "fmt" "strings" "sync" @@ -362,6 +363,20 @@ func TestARepositoryWithNoTrunkCannotBeJudgedLoudlyUntilItsTrunkIsKnown(t *testi } }) } + + // ADR 0664 ยง5 (issue 1748): a candidate taken out (its pull request merged or closed) ends the check running for it with a + // cause its asks' wait names, never a plain cancel, so its asker drops the asks it put on the build nodes. + t.Run("a candidate taken out ends its check with a named cause", func(t *testing.T) { + ch := &Checker{} + ch.init() + run, end := context.WithCancelCause(context.Background()) + ch.live["g.heads"] = liveCheck{group: "g", end: end} + ch.Forget("g") + var s superseded + if cause := context.Cause(run); !errors.As(cause, &s) || s.by != "" || errors.Is(cause, context.Canceled) { + t.Errorf("the check was ended with %v, want superseded with no heads, not a plain cancel", cause) + } + }) } func countWith(lines []string, words string) int {