(t *testing.T)
| 265 | } |
| 266 | |
| 267 | func TestFSServeFileUncompressed(t *testing.T) { |
| 268 | t.Parallel() |
| 269 | |
| 270 | var ctx RequestCtx |
| 271 | ctx.Init(&Request{}, nil, nil) |
| 272 | |
| 273 | var resp Response |
| 274 | |
| 275 | expectedBody, err := getFileContents("/fs.go") |
| 276 | if err != nil { |
| 277 | t.Fatalf("unexpected error: %v", err) |
| 278 | } |
| 279 | |
| 280 | ctx.Request.SetRequestURI("http://foobar.com/baz") |
| 281 | ctx.Request.Header.Set(HeaderAcceptEncoding, "gzip, zstd, br, wompwomp") |
| 282 | ServeFileUncompressed(&ctx, "fs.go") |
| 283 | |
| 284 | s := ctx.Response.String() |
| 285 | br := bufio.NewReader(bytes.NewBufferString(s)) |
| 286 | if err = resp.Read(br); err != nil { |
| 287 | t.Fatalf("unexpected error: %v", err) |
| 288 | } |
| 289 | if resp.StatusCode() != StatusOK { |
| 290 | t.Fatalf("unexpected status code: %d. Expecting %d", resp.StatusCode(), StatusOK) |
| 291 | } |
| 292 | |
| 293 | ce := resp.Header.ContentEncoding() |
| 294 | if len(ce) > 0 { |
| 295 | t.Fatalf("unexpected 'Content-Encoding': %q. Expecting \"\"", string(ce)) |
| 296 | } |
| 297 | |
| 298 | vary := resp.Header.PeekBytes(strVary) |
| 299 | if len(vary) > 0 { |
| 300 | t.Fatalf("unexpected 'Vary': %q. Expecting \"\"", string(vary)) |
| 301 | } |
| 302 | |
| 303 | body := resp.Body() |
| 304 | if !bytes.Equal(body, expectedBody) { |
| 305 | t.Fatalf("unexpected body: len=%d. Expecting len=%d", len(body), len(expectedBody)) |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | func TestFSFSByteRangeConcurrent(t *testing.T) { |
| 310 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…