MCPcopy
hub / github.com/gorilla/mux / TestSubrouterNotFound

Function TestSubrouterNotFound

mux_test.go:2844–2858  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2842}
2843
2844func TestSubrouterNotFound(t *testing.T) {
2845 handler := func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) }
2846 router := NewRouter()
2847 router.Path("/a").Subrouter().HandleFunc("/thing", handler).Methods(http.MethodGet)
2848 router.Path("/b").Subrouter().HandleFunc("/something", handler).Methods(http.MethodGet)
2849
2850 w := NewRecorder()
2851 req := newRequest(http.MethodPut, "/not-present")
2852
2853 router.ServeHTTP(w, req)
2854
2855 if w.Code != http.StatusNotFound {
2856 t.Fatalf("Expected status code 404 (got %d)", w.Code)
2857 }
2858}
2859
2860func TestContextMiddleware(t *testing.T) {
2861 withTimeout := func(h http.Handler) http.Handler {

Callers

nothing calls this directly

Calls 9

PathMethod · 0.95
ServeHTTPMethod · 0.95
NewRouterFunction · 0.85
NewRecorderFunction · 0.85
newRequestFunction · 0.85
HandleFuncMethod · 0.80
SubrouterMethod · 0.80
WriteHeaderMethod · 0.45
MethodsMethod · 0.45

Tested by

no test coverage detected