generated from mathias/template-go-web
fix(test): stop asserting CI job names that the live overlay legitimately replaces
TestAtlasJSON_ServesAtlasWithGeneratedCIStage demanded STAGE 06 contain the
job names parsed from the embedded cd.yml (guard/check/build/deploy). But when
the forge is reachable, the handler deliberately REPLACES those nodes with the
latest real run — live per-job status, which is the whole point of that overlay.
So the test passed on a laptop with no route to Gitea and failed inside CI,
where the overlay works as designed:
CI stage missing generated job "guard"
(got map[Detect unsubstituted template:true Lint / Test / Vet:true
▶ run #62 · running:true])
It went red on a commit that touched only atlas.json — a test that depends on
whether the network is reachable will eventually fail on someone innocent, and
did.
The endpoint test now asserts the shape it serves — STAGE 06 exists, is
populated by whichever source won, and every node has a title. The
deterministic assertion already exists where it belongs, in
TestBuild_OverlaysCIStageNodesFromWorkflow, which feeds Build a fixed workflow
and never touches the network.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011PL5XcG68SvQqz3vGVbWbf
This commit is contained in:
@@ -30,7 +30,20 @@ func TestRootServesAtlas(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAtlasJSON_ServesAtlasWithGeneratedCIStage(t *testing.T) {
|
||||
// This asserts the SHAPE the endpoint serves, not the exact CI job names.
|
||||
//
|
||||
// STAGE 06 has two sources: the embedded workflow (deterministic) and, when the
|
||||
// forge is reachable, the live latest run — which overwrites it with real job
|
||||
// names and a "▶ run #N" node. The old assertion demanded the workflow-derived
|
||||
// names, so it passed on a laptop with no route to Gitea and failed inside CI,
|
||||
// where the overlay works exactly as designed. It went red on 2026-08-19 for a
|
||||
// commit that only touched atlas.json.
|
||||
//
|
||||
// The deterministic assertion lives in the atlas package
|
||||
// (TestBuild_OverlaysCIStageNodesFromWorkflow), which feeds Build a fixed
|
||||
// workflow and no network. Here we check the endpoint serves a usable atlas
|
||||
// whichever source won.
|
||||
func TestAtlasJSON_ServesAtlasWithPopulatedCIStage(t *testing.T) {
|
||||
srv := httptest.NewServer(NewHandler())
|
||||
defer srv.Close()
|
||||
|
||||
@@ -51,18 +64,21 @@ func TestAtlasJSON_ServesAtlasWithGeneratedCIStage(t *testing.T) {
|
||||
t.Fatal("atlas has no stages")
|
||||
}
|
||||
|
||||
// The generate:ci-jobs stage must be populated from the real cd.yml jobs.
|
||||
got := map[string]bool{}
|
||||
for _, s := range a.Stages {
|
||||
if s.No == "STAGE 06" {
|
||||
for _, n := range s.Nodes {
|
||||
got[n.Title] = true
|
||||
}
|
||||
var ci *atlas.Stage
|
||||
for i := range a.Stages {
|
||||
if a.Stages[i].No == "STAGE 06" {
|
||||
ci = &a.Stages[i]
|
||||
}
|
||||
}
|
||||
for _, want := range []string{"guard", "check", "build", "deploy"} {
|
||||
if !got[want] {
|
||||
t.Fatalf("CI stage missing generated job %q (got %v)", want, got)
|
||||
if ci == nil {
|
||||
t.Fatal("STAGE 06 missing from the served atlas")
|
||||
}
|
||||
if len(ci.Nodes) == 0 {
|
||||
t.Fatal("STAGE 06 has no nodes — neither the embedded workflow nor the live run populated it")
|
||||
}
|
||||
for _, n := range ci.Nodes {
|
||||
if n.Title == "" {
|
||||
t.Fatalf("STAGE 06 node with no title: %+v", n)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user