55 lines
1.9 KiB
Go
55 lines
1.9 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/novox/mesh-controller/internal/inventory"
|
|
)
|
|
|
|
func TestAWalkThatMovedNothingSaysWhichModulesMatchedWhatRuns(t *testing.T) {
|
|
open := windowed(t)
|
|
endsItsLine(t)
|
|
asksRecorded(t)
|
|
ctx := t.Context()
|
|
inv := open.inventory
|
|
if err := inv.RecordBuild(ctx, inventory.Build{ID: "build-one", Repository: "novox/one", Ref: "main",
|
|
Module: "one", Commit: "c0", On: "builder", Asked: t0.Add(-time.Hour),
|
|
Sources: []inventory.BuildSource{{Paths: []string{"main.go", "go.mod"}}}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
readme := repoMerge("one", "one1aaaaaaaa", t0)
|
|
readme.Paths = []string{"README.md"}
|
|
hear(t, open, readme, t0.Add(time.Second))
|
|
cutAt(t, open, t0.Add(2*time.Minute))
|
|
ws, _ := walks(t, open)
|
|
if len(ws) != 1 {
|
|
t.Fatalf("walks: %+v", ws)
|
|
}
|
|
w := ws[0]
|
|
if w.State != inventory.PlanDone || len(w.Tiers) != 0 || len(w.Modules) != 0 {
|
|
t.Fatalf("the walk reads %s, tiers %v, modules %v; want done with nothing to walk", w.State, w.Tiers, w.Modules)
|
|
}
|
|
if w.Delivery == nil || !strings.Contains(w.Delivery.Unchanged["one"], "holds none of the 1 changed file(s)") {
|
|
t.Fatalf("the walk does not say one matched what runs: %+v", w.Delivery)
|
|
}
|
|
if !strings.Contains(w.Note, "unchanged") || !strings.Contains(w.Note, "one") {
|
|
t.Errorf("the walk's note does not name it: %q", w.Note)
|
|
}
|
|
|
|
// A merge that changes the build source is walked, and says nothing unchanged.
|
|
code := repoMerge("one", "one2bbbbbbbb", t0.Add(3*time.Minute))
|
|
hear(t, open, code, t0.Add(3*time.Minute+time.Second))
|
|
cutAt(t, open, t0.Add(6*time.Minute))
|
|
ws, _ = walks(t, open)
|
|
if len(ws) != 2 {
|
|
t.Fatalf("walks: %+v", ws)
|
|
}
|
|
if _, built := ws[0].Modules["one"]; !built || ws[0].Delivery == nil || len(ws[0].Delivery.Unchanged) != 0 {
|
|
t.Fatalf("the walk of a change to main.go reads modules %v, delivery %+v", ws[0].Modules, ws[0].Delivery)
|
|
}
|
|
}
|