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

Function TestFSServeFileDirectoryRedirect

fs_fs_test.go:582–610  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

580}
581
582func TestFSServeFileDirectoryRedirect(t *testing.T) {
583 t.Parallel()
584
585 var ctx RequestCtx
586 var req Request
587 req.SetRequestURI("http://foobar.com")
588 ctx.Init(&req, nil, nil)
589
590 ctx.Request.Reset()
591 ctx.Response.Reset()
592 ServeFS(&ctx, fsTestFilesystem, "fasthttputil")
593 if ctx.Response.StatusCode() != StatusFound {
594 t.Fatalf("Unexpected status code %d for directory '/fasthttputil' without trailing slash. Expecting %d.", ctx.Response.StatusCode(), StatusFound)
595 }
596
597 ctx.Request.Reset()
598 ctx.Response.Reset()
599 ServeFS(&ctx, fsTestFilesystem, "fasthttputil/")
600 if ctx.Response.StatusCode() != StatusOK {
601 t.Fatalf("Unexpected status code %d for directory '/fasthttputil/' with trailing slash. Expecting %d.", ctx.Response.StatusCode(), StatusOK)
602 }
603
604 ctx.Request.Reset()
605 ctx.Response.Reset()
606 ServeFS(&ctx, fsTestFilesystem, "fs.go")
607 if ctx.Response.StatusCode() != StatusOK {
608 t.Fatalf("Unexpected status code %d for file '/fs.go'. Expecting %d.", ctx.Response.StatusCode(), StatusOK)
609 }
610}
611
612var dirTestFilesystem = os.DirFS(".")
613

Callers

nothing calls this directly

Calls 5

SetRequestURIMethod · 0.95
InitMethod · 0.95
ServeFSFunction · 0.85
ResetMethod · 0.65
StatusCodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…