MCPcopy
hub / github.com/julienschmidt/httprouter / TestRouterServeFiles

Function TestRouterServeFiles

router_test.go:584–602  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

582}
583
584func TestRouterServeFiles(t *testing.T) {
585 router := New()
586 mfs := &mockFileSystem{}
587
588 recv := catchPanic(func() {
589 router.ServeFiles("/noFilepath", mfs)
590 })
591 if recv == nil {
592 t.Fatal("registering path not ending with '*filepath' did not panic")
593 }
594
595 router.ServeFiles("/*filepath", mfs)
596 w := new(mockResponseWriter)
597 r, _ := http.NewRequest(http.MethodGet, "/favicon.ico", nil)
598 router.ServeHTTP(w, r)
599 if !mfs.opened {
600 t.Error("serving file failed")
601 }
602}

Callers

nothing calls this directly

Calls 4

NewFunction · 0.85
catchPanicFunction · 0.85
ServeFilesMethod · 0.80
ServeHTTPMethod · 0.45

Tested by

no test coverage detected