Skip to content
quarry Artifact [d01089b18b]
Login

Artifact [d01089b18b]

Artifact d01089b18b32dac1c31cd60376884af61b5dc70a63675b2db003a7dc25fa1aab:


package api

import "testing"

// WAITING WITH A RUN ON THE WAY IS NOT WAITING WITH NONE.
//
// A required check with no run for the merge, while nothing answering
// a required check is queued or going, is Untested: the landing page
// says the merge has not been tested as it is now and offers the re-run.
func TestJudgeRowsSaysWhenNoRunIsOnTheWay(t *testing.T) {
	both := []string{"quarry", "race"}
	for _, c := range []struct {
		name string
		in   judgeIn
		want bool
	}{
		{"no rows at all", judgeIn{Merge: true, Required: both}, true},
		{"one of two ran green, the other has no run", judgeIn{Merge: true, Required: both, Rows: []CIRun{row("quarry", "completed")}}, true},
		{"only a cancelled run", judgeIn{Merge: true, Required: both, Rows: []CIRun{row("quarry", "cancelled"), row("race", "cancelled")}}, true},
		{"the missing one is queued", judgeIn{Merge: true, Required: both, Rows: []CIRun{row("quarry", "running")}}, false},
		{"the other is queued for a runner", judgeIn{Merge: true, Required: both, Rows: []CIRun{row("quarry", RunUnclaimed)}}, false},
		{"all green", judgeIn{Merge: true, Required: both, Rows: []CIRun{row("quarry", "completed"), row("race", "completed")}}, false},
		{"nothing required", judgeIn{Merge: true}, false},
	} {
		if got := judgeRows(c.in); got.Untested != c.want {
			t.Errorf("FAIL: %s: Untested = %v, want %v", c.name, got.Untested, c.want)
		}
	}
	if got := judgeRows(judgeIn{Merge: true, Required: both}); got.Verdict != "ci-waiting" {
		t.Errorf("FAIL: untested verdict = %q, want ci-waiting kept", got.Verdict)
	}
	if !t.Failed() {
		t.Log("ok")
	}
}