(t *testing.T, pathNotFoundFunc RequestHandler)
| 82 | } |
| 83 | |
| 84 | func 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 | |
| 117 | func TestPathNotFound(t *testing.T) { |
| 118 | t.Parallel() |
no test coverage detected
searching dependent graphs…