package screenmatch import ( "net/http" "strings" "testing" "github.com/go-chi/chi/v5" "github.com/missionworkforce/missionmatch/internal/modules/matching" ) // TestNamespaceExposesScreenRoutes proves the screenMATCH namespace mounts the screening endpoints and // the shared pickers over the shared core, and NOT the slate write endpoints (those belong to // slateMATCH). It walks the registered routes rather than calling them, so it needs no database or // session. The same handlers also serve the flat alias paths from matching.Handler.Routes. func TestNamespaceExposesScreenRoutes(t *testing.T) { h := NewHandler(matching.NewHandler(matching.NewService(nil, nil, nil))) r := chi.NewRouter() r.Route("/screenmatch", h.Routes) routes := map[string]bool{} if err := chi.Walk(r, func(method, route string, _ http.Handler, _ ...func(http.Handler) http.Handler) error { routes[method+" "+route] = true return nil }); err != nil { t.Fatalf("walk: %v", err) } want := []string{ "POST /screenmatch/screen", "POST /screenmatch/match", "GET /screenmatch/requirements/{requirementID}/candidates", "GET /screenmatch/requirements", "GET /screenmatch/requirements/{requirementID}", "GET /screenmatch/candidates", "GET /screenmatch/candidates/{candidateID}", "GET /screenmatch/candidates/{candidateID}/opportunities", } for _, w := range want { if !routes[w] { t.Errorf("screenMATCH namespace missing route %q (have: %s)", w, strings.Join(keys(routes), ", ")) } } // The slate write must NOT leak into screenMATCH; it is slateMATCH's surface. for r := range routes { if strings.Contains(r, "/slates/") { t.Errorf("screenMATCH namespace must not expose a slate route, found %q", r) } } } func keys(m map[string]bool) []string { out := make([]string, 0, len(m)) for k := range m { out = append(out, k) } return out }