Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/opportunities/capture_handler_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/opportunities/capture_handler_test.go |
| Original SHA-256 | 123c9bacc1830dca50517b787adf800b4fe6a5cd423dc25e1ffea91658226dbf |
| Git blob SHA | 65fafd3e59a1c955f73ed5910ffc2dfb44db2616 |
| Reading-copy SHA-256 | 123c9bacc1830dca50517b787adf800b4fe6a5cd423dc25e1ffea91658226dbf |
Recovered source transcript
Download complete source text ↓57 lines · 2.3 KB
package opportunities
import (
"net/http"
"testing"
"github.com/go-chi/chi/v5"
)
// TestCaptureRoutesRegister is the module level route contract: it asserts the tenant capture surface mounts
// exactly the expected method and path set. It does not touch the database; it proves the wiring, so a route
// dropped or renamed in a refactor fails here rather than in production.
func TestCaptureRoutesRegister(t *testing.T) {
h := NewHandler(NewService(nil, nil))
r := chi.NewRouter()
h.CaptureRoutes(r)
got := map[string]bool{}
err := chi.Walk(r, func(method, route string, _ http.Handler, _ ...func(http.Handler) http.Handler) error {
got[method+" "+route] = true
return nil
})
if err != nil {
t.Fatalf("walking the capture router: %v", err)
}
want := []string{
"POST /opportunities/tracked",
"GET /opportunities/tracked",
"GET /opportunities/tracked/{id}",
"PATCH /opportunities/tracked/{id}",
"GET /opportunities/tracked/{id}/scope",
"POST /opportunities/tracked/{id}/scope/items",
"PATCH /opportunities/tracked/{id}/scope/items/{item_id}",
// Split and merge, Phase 2 item 4. They are listed here because the contract test only asserts what it
// is TOLD to expect: an unlisted route passes silently, so adding a route without adding it here leaves
// it unguarded, which is exactly how the promotion routes once sat unmounted.
"POST /opportunities/tracked/{id}/scope/items/{item_id}/split",
"POST /opportunities/tracked/{id}/scope/items/{item_id}/merge",
"GET /opportunities/tracked/{id}/requirement-drafts",
// Generation and manual completion, Phase 2 item 5. Both are held at scope.review, deliberately below
// the promotion gate, so shaping a draft can never be the same act as making it live.
"POST /opportunities/tracked/{id}/requirement-drafts/generate",
"PATCH /requirement-drafts/{id}",
"GET /opportunities/tracked/{id}/amendments",
// The promotion gate. If either of these is ever unmounted, the safety path that lets a named human
// turn a draft into a live requirement becomes unreachable, which is how it sat before this test.
"POST /requirement-drafts/{id}/approve",
"POST /requirement-drafts/{id}/reject",
}
for _, route := range want {
if !got[route] {
t.Errorf("capture route not registered: %s", route)
}
}
}