Release 6 deletes the plans: the walk half of the holder, the controller port, the carry-over of the former module and the verbs times, what-if, release, stop and retire-history go; the table holds proposed, ready, rejected, merged, held and closed; the delivery's status and view name the source revision the merge moved.
71 lines
2.1 KiB
Go
71 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// novox/hq issue 326: a delivery whose state did not change is not written again — a pass over deliveries that did not
|
|
// move writes nothing — and one that changed is written, and said.
|
|
func TestADeliveryIsWrittenOnlyWhenItChanged(t *testing.T) {
|
|
w := newWorld(t)
|
|
id := IDOf("novox/app", head)
|
|
w.h.PullUpdated(pr("novox/app", 7, head, "feat/x", "src/a.go"))
|
|
w.h.Checked(verdict("novox/app", 7, head, "pass"))
|
|
w.settleAll()
|
|
if w.state(id) != Ready {
|
|
t.Fatalf("it is %s", w.state(id))
|
|
}
|
|
|
|
// Passes over the same deliveries, as every event asks for one: nothing changed, nothing written.
|
|
before, said := w.store.puts, len(w.said)
|
|
for range 5 {
|
|
w.later(30 * time.Second)
|
|
w.settleAll()
|
|
}
|
|
if w.store.puts != before {
|
|
t.Fatalf("five passes over deliveries that did not move wrote %d delivery(ies)", w.store.puts-before)
|
|
}
|
|
if len(w.said) != said {
|
|
t.Fatalf("five passes over deliveries that did not move said %d event(s)", len(w.said)-said)
|
|
}
|
|
|
|
// The merge is heard: the delivery changes, is written, and is said.
|
|
w.h.PullMerged(merged("novox/app", 7, head, merge))
|
|
w.settleAll()
|
|
if w.state(id) != Merged {
|
|
t.Fatalf("a merge left it %s", w.state(id))
|
|
}
|
|
if w.store.puts == before {
|
|
t.Fatal("a delivery that changed was not written")
|
|
}
|
|
back, err := w.store.Deliveries()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, d := range back {
|
|
if d.ID == id && d.State != Merged {
|
|
t.Fatalf("the store holds it %s, the holder %s", d.State, Merged)
|
|
}
|
|
}
|
|
if len(w.said) == said {
|
|
t.Fatal("a delivery that changed was not said")
|
|
}
|
|
}
|
|
|
|
// A delivery that could not be written is written again, even though it did not change since.
|
|
func TestADeliveryNotWrittenIsWrittenAgainUnchanged(t *testing.T) {
|
|
w := newWorld(t)
|
|
id := IDOf("novox/app", head)
|
|
w.store.failing = true
|
|
w.h.PullUpdated(pr("novox/app", 7, head, "feat/x", "src/a.go"))
|
|
if _, there := w.store.deliveries[id]; there {
|
|
t.Fatal("a failing store kept it")
|
|
}
|
|
w.store.failing = false
|
|
w.h.Flush()
|
|
if _, there := w.store.deliveries[id]; !there {
|
|
t.Fatal("a delivery that could not be written was not written again")
|
|
}
|
|
}
|