MCPcopy
hub / github.com/go-chi/chi / TestMuxEmptyRoutes

Function TestMuxEmptyRoutes

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

Source from the content-addressed store, hash-verified

264}
265
266func TestMuxEmptyRoutes(t *testing.T) {
267 mux := NewRouter()
268
269 apiRouter := NewRouter()
270 // oops, we forgot to declare any route handlers
271
272 mux.Handle("/api*", apiRouter)
273
274 if _, body := testHandler(t, mux, "GET", "/", nil); body != "404 page not found\n" {
275 t.Fatal(body)
276 }
277
278 if _, body := testHandler(t, apiRouter, "GET", "/", nil); body != "404 page not found\n" {
279 t.Fatal(body)
280 }
281}
282
283// Test a mux that routes a trailing slash, see also middleware/strip_test.go
284// for an example of using a middleware to handle trailing slashes.

Callers

nothing calls this directly

Calls 3

HandleMethod · 0.95
NewRouterFunction · 0.85
testHandlerFunction · 0.85

Tested by

no test coverage detected