49 lines
1.9 KiB
Go
49 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// **An unanswered line says the state of the delivery it holds, as data** (novox/hq issue 451): for a delivery in
|
|
// ready or rejected, whose check answered once, the controller advises a recheck rather than the build queue, and
|
|
// it reads that state from the line, never from its words. A head with no delivery held says none.
|
|
func TestAnUnansweredLineNamesTheStateOfItsDelivery(t *testing.T) {
|
|
at := time.Date(2026, 10, 11, 0, 43, 0, 0, time.UTC)
|
|
for _, c := range []struct {
|
|
gate string
|
|
want State
|
|
}{{"pass", Ready}, {"fail", Rejected}} {
|
|
w := newWorldOver(t, newMemStore(), newFakeController(), newFakeForge(), at)
|
|
id := heldIn(t, w, c.gate, c.want)
|
|
w.forge.open = openPullsOf(t, readyRepoCheckPending)
|
|
w.h.SeeOpenPulls()
|
|
w.later(Bounds[Proposed].For + time.Minute)
|
|
w.h.SeeOpenPulls()
|
|
lines := w.h.Stalled()
|
|
if len(lines) != 1 || lines[0].ID != id || lines[0].State != Unanswered || lines[0].Held != c.want {
|
|
t.Fatalf("a %s delivery's unanswered line does not say its state as data: %+v", c.want, lines)
|
|
}
|
|
raw, _ := json.Marshal(lines[0])
|
|
if !strings.Contains(string(raw), `"held":"`+string(c.want)+`"`) {
|
|
t.Fatalf("the line the controller reads carries no held state: %s", raw)
|
|
}
|
|
}
|
|
|
|
// The same head with no delivery held here: unanswered, and no state to say.
|
|
w := newWorldOver(t, newMemStore(), newFakeController(), newFakeForge(), at)
|
|
w.forge.open = openPullsOf(t, readyRepoCheckPending)
|
|
w.h.SeeOpenPulls()
|
|
w.later(Bounds[Proposed].For + time.Minute)
|
|
w.h.SeeOpenPulls()
|
|
lines := w.h.Stalled()
|
|
if len(lines) != 1 || lines[0].State != Unanswered || lines[0].Held != "" {
|
|
t.Fatalf("a head with no delivery held says a state: %+v", lines)
|
|
}
|
|
if raw, _ := json.Marshal(lines[0]); strings.Contains(string(raw), `"held"`) {
|
|
t.Fatalf("a line with no delivery held carries a held field: %s", raw)
|
|
}
|
|
}
|