MCPcopy
hub / github.com/valyala/fasthttp / testPathNotFound

Function testPathNotFound

fs_test.go:84–115  ·  view source on GitHub ↗
(t *testing.T, pathNotFoundFunc RequestHandler)

Source from the content-addressed store, hash-verified

82}
83
84func testPathNotFound(t *testing.T, pathNotFoundFunc RequestHandler) {
85 t.Helper()
86
87 var ctx RequestCtx
88 var req Request
89 req.SetRequestURI("http//some.url/file")
90 ctx.Init(&req, nil, TestLogger{t: t})
91
92 stop := make(chan struct{})
93 defer close(stop)
94
95 fs := &FS{
96 Root: "./",
97 PathNotFound: pathNotFoundFunc,
98 CleanStop: stop,
99 }
100 fs.NewRequestHandler()(&ctx)
101
102 if pathNotFoundFunc == nil {
103 // different to ...
104 if !bytes.Equal(ctx.Response.Body(),
105 []byte("Cannot open requested path")) {
106 t.Fatalf("response defers. Response: %q", ctx.Response.Body())
107 }
108 } else {
109 // Equals to ...
110 if bytes.Equal(ctx.Response.Body(),
111 []byte("Cannot open requested path")) {
112 t.Fatalf("response defers. Response: %q", ctx.Response.Body())
113 }
114 }
115}
116
117func TestPathNotFound(t *testing.T) {
118 t.Parallel()

Callers 2

TestPathNotFoundFunction · 0.85
TestPathNotFoundFuncFunction · 0.85

Calls 4

SetRequestURIMethod · 0.95
InitMethod · 0.95
NewRequestHandlerMethod · 0.95
BodyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…