ISSUES: mesh-issues reads git.pull, git.contains and the runner's list and show, not mesh-delivery.checks and the forge's tools
Pull request facts come from seat git's pull, ancestry from contains, the review time from the runner's review step, and get shows one pipeline row per module (no run where the runner's list answers none). Builds: design 47 G §654, A-75 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -441,50 +441,33 @@ func TestAFixWhoseStartCameFromTheLogIsNeverWarnedOn(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The forge's reviews: the first approval at the head, never one dismissed, stale or of an older head.
|
||||
func TestTheReviewEndsAtTheFirstApprovalAtItsHead(t *testing.T) {
|
||||
raw := json.RawMessage(`{"reviews":[
|
||||
{"state":"APPROVED","at_head":false,"submitted":"2026-10-12T09:01:00Z"},
|
||||
{"state":"REQUEST_CHANGES","at_head":true,"submitted":"2026-10-12T09:02:00Z"},
|
||||
{"state":"APPROVED","at_head":true,"dismissed":true,"submitted":"2026-10-12T09:03:00Z"},
|
||||
{"state":"APPROVED","at_head":true,"submitted":"2026-10-12T09:05:00Z"},
|
||||
{"state":"APPROVED","at_head":true,"submitted":"2026-10-12T09:04:00Z"}]}`)
|
||||
at, found, err := firstApproval(raw)
|
||||
if err != nil || !found || at.Format(time.RFC3339) != "2026-10-12T09:04:00Z" {
|
||||
t.Fatalf("%s %v %v", at, found, err)
|
||||
}
|
||||
// The mesh's own reviews: comments by the account that opened the pull request, whose first line is the verdict.
|
||||
head := "43df7ebc5aa21c0bceacd1580f01f67d83d3495d"
|
||||
comments := json.RawMessage(`{"reviews":[
|
||||
{"state":"COMMENT","at_head":true,"commit":"` + head + `","body":"Verdict: request changes at ` + head + `\n\nBlocking: …","submitted":"2026-10-12T09:01:00Z"},
|
||||
{"state":"COMMENT","at_head":true,"commit":"` + head + `","body":"Looks fine. Verdict: approve at ` + head + `","submitted":"2026-10-12T09:02:00Z"},
|
||||
{"state":"COMMENT","at_head":true,"commit":"` + head + `","body":"Verdict: approve at 43df7eb\n\nAll clauses hold.","submitted":"2026-10-12T09:07:00Z"},
|
||||
{"state":"COMMENT","at_head":true,"commit":"` + head + `","body":"Verdict: approve at ` + head + `\n\nAgain.","submitted":"2026-10-12T09:08:00Z"}]}`)
|
||||
at, found, err = firstApproval(comments)
|
||||
if err != nil || !found || at.Format(time.RFC3339) != "2026-10-12T09:07:00Z" {
|
||||
t.Fatalf("a comment's verdict: %s %v %v", at, found, err)
|
||||
}
|
||||
for _, c := range []struct {
|
||||
body, commit string
|
||||
approves bool
|
||||
}{
|
||||
{"Verdict: approve at " + head, head, true},
|
||||
{"Verdict: approve at 43df7eb", head, true},
|
||||
{"Verdict: approve at 43df7e", head, false}, // shorter than seven characters
|
||||
{"Verdict: approve at 0123456789", head, false}, // another commit
|
||||
{"Verdict: request changes at " + head, head, false}, // not an approval
|
||||
{"Not yet.\nVerdict: approve at " + head, head, false}, // not the first line
|
||||
{"Verdict: approve at 43df7ebc", "", false}, // no commit to hold it to
|
||||
} {
|
||||
if got := verdictApproves(c.body, c.commit); got != c.approves {
|
||||
t.Errorf("%q at %q approves %v, want %v", c.body, c.commit, got, c.approves)
|
||||
// The runner's review step: the first review that passed among a pull request's pipelines, never one that failed or waits.
|
||||
func TestTheReviewEndsAtTheFirstPassedReviewStepOfTheRunner(t *testing.T) {
|
||||
show := func(outcome, ended string) PipelineRow {
|
||||
step := `{"step":"lint","outcome":"passed"},{"step":"review","outcome":"` + outcome + `"`
|
||||
if ended != "" {
|
||||
step += `,"ended":"` + ended + `"`
|
||||
}
|
||||
row, err := parsePipelineRow(json.RawMessage(`{"pipeline":{"pipeline":"b.1.m","module":"m","outcome":"passed","steps":[`+step+`}]}}`), "r#1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return row
|
||||
}
|
||||
if _, found, err := firstApproval(json.RawMessage(`{"reviews":[]}`)); err != nil || found {
|
||||
t.Fatalf("no reviews: %v %v", found, err)
|
||||
rows := []PipelineRow{show("failed", "2026-10-12T09:01:00Z"), show("passed", "2026-10-12T09:05:00Z"),
|
||||
show("accepted", "2026-10-12T09:04:00Z"), show("waiting", "")}
|
||||
at, found := firstReview(rows)
|
||||
if !found || at.Format(time.RFC3339) != "2026-10-12T09:04:00Z" {
|
||||
t.Fatalf("%s %v", at, found)
|
||||
}
|
||||
if _, _, err := firstApproval(json.RawMessage(`"nothing"`)); err == nil {
|
||||
t.Fatal("an answer with no reviews read as none")
|
||||
if _, found := firstReview(rows[:1]); found {
|
||||
t.Fatal("a failed review read as passed")
|
||||
}
|
||||
if _, found := firstReview([]PipelineRow{{Outcome: NoRun}}); found {
|
||||
t.Fatal("no run read as reviewed")
|
||||
}
|
||||
if _, err := parsePipelineRow(json.RawMessage(`{"error":"no such pipeline"}`), "r#1"); err == nil {
|
||||
t.Fatal("a failed show read as a pipeline")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user