Two fresh-context reviews of the preceding five fixes found that the tests were mostly sound but that three things were not: one harness was coupled to shell source text, one assertion was coupled to a tool count, and -- worse -- the two changes carrying the most weight were pinned by nothing at all. Composition order. review_pr worked only because Run builds the worktree manager before the gateways; no test observed it. Reverting the order left every test green while the daemon silently stopped offering review_pr, because the producer guard then returns nil instead of advertising a broken tool. Pin the order by source position, matching the existing TestSetupBackendsRegistersContainerCleanupAfterNATS, since no runtime seam can see it. methodBody now resolves package-level funcs as well as methods. Composition wiring. The daemon fix's whole point is that resolved routing bindings reach the worker, yet nothing verified that buildDaemon puts them on the daemon: with b.kindWorkflows replaced by nil, only the new test fails and both the daemon and worker packages stay green. That is the "tested in isolation, never verified wired" shape this work exists to remove, so pin the hop. The wire contract itself. taskrun.Request's json tags are the interface between two binaries, and a same-type round trip cannot see a tag rename. Assert the emitted keys literally; renaming one now fails with the key list. Brittleness. selfHostConfig no longer string-matches install.sh's heredoc opener or assumes the delimiter is EOF, and no longer hand-substitutes a copy of forge_block's output -- it discovers heredocs by shape and selects the one declaring [nats], a table the assertions never touch. Verified against four behaviour-preserving refactors that previously failed: renaming the delimiter, reordering the redirect, factoring the path into a variable, and <<-. The two [services.gateway] source greps are gone: defaults.go already supplies that target, so there was no behaviour to pin. review_pr is asserted present by name rather than by entry count, so a sibling review tool cannot turn it red. Also carry the published request's decode error instead of discarding it, so a payload-shape break reports as itself rather than as an empty routing binding. Every new test was verified non-vacuous by reintroducing the defect.
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package archied
|
|
|
|
import (
|
|
"go/parser"
|
|
"go/token"
|
|
"testing"
|
|
)
|
|
|
|
// TestRunBuildsWorktreeManagerBeforeGateways pins the composition order that
|
|
// review_pr depends on.
|
|
//
|
|
// boot.prReviewer captures b.trees, and it refuses to produce a reviewer when
|
|
// b.trees is nil so that a process which can never run a review does not
|
|
// advertise the tool. In the daemon that makes the order load-bearing: if the
|
|
// gateway wiring runs first it asks for a reviewer before the worktree manager
|
|
// exists, gets nil, and the daemon silently offers no review_pr at all. Nothing
|
|
// at runtime observes the order, so it is asserted by source position, the same
|
|
// way TestSetupBackendsRegistersContainerCleanupAfterNATS in
|
|
// bootstrap_nats_test.go pins cleanup ordering for the same reason.
|
|
func TestRunBuildsWorktreeManagerBeforeGateways(t *testing.T) {
|
|
fileset := token.NewFileSet()
|
|
file, err := parser.ParseFile(fileset, "main.go", nil, 0)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
run := methodBody(t, file, "Run")
|
|
trees := methodCallPosition(run, "buildTreesAndIdentities")
|
|
gateways := methodCallPosition(run, "setupGateways")
|
|
if trees == token.NoPos || gateways == token.NoPos {
|
|
t.Fatalf("Run call positions: buildTreesAndIdentities=%v setupGateways=%v, want both present", trees, gateways)
|
|
}
|
|
if gateways < trees {
|
|
t.Fatal("Run wires the gateways before buildTreesAndIdentities; prReviewer captures b.trees, so review_pr would be dropped instead of advertised")
|
|
}
|
|
}
|