Probe test lives beside the handler (webtest's test-line budget)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+38
−50
internal/web/team_probe_internal_test.go+38 −0internal/webtest/team_probe_test.go+0 −50
CI passed — run details
CI log
=== build === CGO_ENABLED=0 go build ./... === vet === go vet ./... === fmt-check === === staticcheck === go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./... === govulncheck === go run golang.org/x/vuln/cmd/govulncheck@v1.8.0 ./... No vulnerabilities found. === gitleaks === [90m1:22PM[0m [32mINF[0m [1mUnknown SCM platform. Use --platform to include links in findings.[0m [36mhost=[0mamadan.net [90m1:22PM[0m [32mINF[0m [1m1 commits scanned.[0m [90m1:22PM[0m [32mINF[0m [1mscanned ~2938298 bytes (2.94 MB) in 460ms[0m [90m1:22PM[0m [32mINF[0m [1mno leaks found[0m === budget === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget size budget size: 22 directories within budget === script-test === scripts/prepare-apps_test.sh ok releases lookup failure stops before ship ok app owned elsewhere stops the script ok apps listing failure stops before create ok ambiguous release dir is refused ok explicit version resolves the ambiguity ok releases match is exact, not substring ok shipped version is only promoted, existing app not created ok fresh account creates, ships, promotes to edge, enables ok failing promote stops the script ok ship is retried while uploads are rate limited all passed hack/fonts_test.sh fonts_test: ok === test === go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./... receipt: test step 11.8s against a 60s target (the gate's other steps are not in this figure) receipt: 16 packages ran, 0 cached, 6 without tests, 0 failed receipt: slow package 10.074s amadan.net/oficina/base/internal/webtest receipt: slow package 939ms amadan.net/oficina/base/internal/issuer receipt: slow package 721ms amadan.net/oficina/base/internal/equipo receipt: slow package 720ms amadan.net/oficina/base/internal/operations receipt: slow package 429ms amadan.net/oficina/base/internal/consumer receipt: slow test 1.52s amadan.net/oficina/base/internal/webtest TestHomeDoesNotWaitOnAStalledSnapshot receipt: slow test 1.11s amadan.net/oficina/base/internal/webtest TestAskZoneIsToldOnce receipt: slow test 630ms amadan.net/oficina/base/internal/webtest TestAskUploadStalledBodyFreesItsSlot receipt: slow test 560ms amadan.net/oficina/base/internal/issuer TestAuthorizeRefusals receipt: slow test 540ms amadan.net/oficina/base/internal/operations TestOperationsRefusals === native === strings: copy review's strings.json is not here (git-ignored); its comparison skipped strings: 121 in the catalog, 118 used worktree-lib_test: ok
diff --git a/internal/web/team_probe_internal_test.go b/internal/web/team_probe_internal_test.go| new file mode 100644 |
| index 0000000..dca0f56 |
| --- /dev/null |
| +++ b/internal/web/team_probe_internal_test.go |
| @@ -0,0 +1,38 @@ |
| +package web |
| + |
| +import ( |
| + "encoding/json" |
| + "net/http/httptest" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/home/connect" |
| +) |
| + |
| +// GET /api/team is Alta's readiness probe for a team Base (seeded mode). |
| +func TestTeamProbe(t *testing.T) { |
| + probe := func(a *app) *httptest.ResponseRecorder { |
| + w := httptest.NewRecorder() |
| + a.teamProbe(w, httptest.NewRequest("GET", "/api/team", nil)) |
| + return w |
| + } |
| + a, _, _ := teamApp(t) |
| + if w := probe(a); w.Code != 404 { |
| + t.Fatalf("without Oficina ID: %d %s", w.Code, w.Body) |
| + } |
| + a.cfg.Home = &connect.DecodedCredentials{ConsumerID: "campbells-base"} |
| + w := probe(a) |
| + if w.Code != 200 || w.Header().Get("Content-Type") != "application/json" || w.Header().Get("Cache-Control") != "no-store" || strings.Contains(w.Body.String(), "@") { |
| + t.Fatalf("%d %v %s", w.Code, w.Header(), w.Body) |
| + } |
| + var got map[string]any |
| + if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil || len(got) != 4 || got["team_mode"] != false || got["seeded"] != true || got["consumer"] != "campbells-base" || got["roster"] != "ok" { |
| + t.Fatalf("%v %s", err, w.Body) |
| + } |
| + if _, err := a.db.Exec(`UPDATE members SET role = 'member' WHERE role = 'owner'`); err != nil { |
| + t.Fatal(err) |
| + } |
| + if w := probe(a); !strings.Contains(w.Body.String(), `"roster":"owner-pending"`) { |
| + t.Fatalf("%s", w.Body) |
| + } |
| +} |
diff --git a/internal/webtest/team_probe_test.go b/internal/webtest/team_probe_test.go| deleted file mode 100644 |
| index dff939e..0000000 |
| --- a/internal/webtest/team_probe_test.go |
| +++ /dev/null |
| @@ -1,50 +0,0 @@ |
| -package webtest |
| - |
| -import ( |
| - "encoding/json" |
| - "strings" |
| - "testing" |
| -) |
| - |
| -// GET /api/team is Alta's readiness probe for a team Base (seeded mode). |
| -func TestTeamProbeSeeded(t *testing.T) { |
| - a := newHomeApp(t) |
| - r := a.get("/api/team") |
| - if r.Code != 200 || r.Header.Get("Content-Type") != "application/json" || r.Header.Get("Cache-Control") != "no-store" { |
| - t.Fatalf("%d %v %s", r.Code, r.Header, r.Body) |
| - } |
| - if strings.Contains(r.Body, "@") { |
| - t.Fatalf("probe carries an address: %s", r.Body) |
| - } |
| - var got map[string]any |
| - if err := json.Unmarshal([]byte(r.Body), &got); err != nil { |
| - t.Fatal(err) |
| - } |
| - want := map[string]any{"team_mode": false, "seeded": true, "consumer": homeConsumer, "roster": "ok"} |
| - if len(got) != len(want) { |
| - t.Fatalf("fields %v", got) |
| - } |
| - for k, v := range want { |
| - if got[k] != v { |
| - t.Fatalf("%s = %v, want %v (%s)", k, got[k], v, r.Body) |
| - } |
| - } |
| -} |
| - |
| -func TestTeamProbeOwnerPending(t *testing.T) { |
| - a := newHomeApp(t) |
| - if _, err := a.DB.Exec(`UPDATE members SET role = 'member' WHERE role = 'owner'`); err != nil { |
| - t.Fatal(err) |
| - } |
| - r := a.get("/api/team") |
| - if r.Code != 200 || !strings.Contains(r.Body, `"roster":"owner-pending"`) { |
| - t.Fatalf("%d %s", r.Code, r.Body) |
| - } |
| -} |
| - |
| -func TestTeamProbeWithoutOficinaID(t *testing.T) { |
| - a := newApp(t) |
| - if r := a.get("/api/team"); r.Code != 404 { |
| - t.Fatalf("%d %s", r.Code, r.Body) |
| - } |
| -} |