MCPcopy
hub / github.com/pocketbase/pocketbase / TestFileSystemAttributes

Function TestFileSystemAttributes

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

Source from the content-addressed store, hash-verified

55}
56
57func TestFileSystemAttributes(t *testing.T) {
58 dir := createTestDir(t)
59 defer os.RemoveAll(dir)
60
61 fsys, err := filesystem.NewLocal(dir)
62 if err != nil {
63 t.Fatal(err)
64 }
65 defer fsys.Close()
66
67 scenarios := []struct {
68 file string
69 expectError bool
70 expectContentType string
71 }{
72 {"sub1.txt", true, ""},
73 {"test/sub1.txt", false, "application/octet-stream"},
74 {"test/sub2.txt", false, "application/octet-stream"},
75 {"image.png", false, "image/png"},
76 }
77
78 for _, s := range scenarios {
79 t.Run(s.file, func(t *testing.T) {
80 attr, err := fsys.Attributes(s.file)
81
82 hasErr := err != nil
83
84 if hasErr != s.expectError {
85 t.Fatalf("Expected hasErr %v, got %v", s.expectError, hasErr)
86 }
87
88 if hasErr && !errors.Is(err, filesystem.ErrNotFound) {
89 t.Fatalf("Expected ErrNotFound err, got %q", err)
90 }
91
92 if !hasErr && attr.ContentType != s.expectContentType {
93 t.Fatalf("Expected attr.ContentType to be %q, got %q", s.expectContentType, attr.ContentType)
94 }
95 })
96 }
97}
98
99func TestFileSystemDelete(t *testing.T) {
100 dir := createTestDir(t)

Callers

nothing calls this directly

Calls 7

NewLocalFunction · 0.92
IsMethod · 0.80
createTestDirFunction · 0.70
CloseMethod · 0.65
AttributesMethod · 0.65
RemoveAllMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…