MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / TestFileSystemServeSingleRange

Function TestFileSystemServeSingleRange

tools/filesystem/filesystem_test.go:812–844  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

810}
811
812func TestFileSystemServeSingleRange(t *testing.T) {
813 dir := createTestDir(t)
814 defer os.RemoveAll(dir)
815
816 fsys, err := filesystem.NewLocal(dir)
817 if err != nil {
818 t.Fatal(err)
819 }
820 defer fsys.Close()
821
822 res := httptest.NewRecorder()
823 req := httptest.NewRequest("GET", "/", nil)
824 req.Header.Add("Range", "bytes=0-20")
825
826 if err := fsys.Serve(res, req, "image.png", "image.png"); err != nil {
827 t.Fatal(err)
828 }
829
830 result := res.Result()
831
832 if result.StatusCode != http.StatusPartialContent {
833 t.Fatalf("Expected StatusCode %d, got %d", http.StatusPartialContent, result.StatusCode)
834 }
835
836 expectedRange := "bytes 0-20/73"
837 if cr := result.Header.Get("Content-Range"); cr != expectedRange {
838 t.Fatalf("Expected Content-Range %q, got %q", expectedRange, cr)
839 }
840
841 if l := result.Header.Get("Content-Length"); l != "21" {
842 t.Fatalf("Expected Content-Length %v, got %v", 21, l)
843 }
844}
845
846func TestFileSystemServeMultiRange(t *testing.T) {
847 dir := createTestDir(t)

Callers

nothing calls this directly

Calls 7

NewLocalFunction · 0.92
ServeMethod · 0.80
createTestDirFunction · 0.70
CloseMethod · 0.65
GetMethod · 0.65
RemoveAllMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…