MCPcopy
hub / github.com/pocketbase/pocketbase / TestFileSystemExists

Function TestFileSystemExists

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

Source from the content-addressed store, hash-verified

20)
21
22func TestFileSystemExists(t *testing.T) {
23 dir := createTestDir(t)
24 defer os.RemoveAll(dir)
25
26 fsys, err := filesystem.NewLocal(dir)
27 if err != nil {
28 t.Fatal(err)
29 }
30 defer fsys.Close()
31
32 scenarios := []struct {
33 file string
34 exists bool
35 }{
36 {"sub1.txt", false},
37 {"test/sub1.txt", true},
38 {"test/sub2.txt", true},
39 {"image.png", true},
40 }
41
42 for _, s := range scenarios {
43 t.Run(s.file, func(t *testing.T) {
44 exists, err := fsys.Exists(s.file)
45
46 if err != nil {
47 t.Fatal(err)
48 }
49
50 if exists != s.exists {
51 t.Fatalf("Expected exists %v, got %v", s.exists, exists)
52 }
53 })
54 }
55}
56
57func TestFileSystemAttributes(t *testing.T) {
58 dir := createTestDir(t)

Callers

nothing calls this directly

Calls 6

NewLocalFunction · 0.92
createTestDirFunction · 0.70
CloseMethod · 0.65
RemoveAllMethod · 0.45
RunMethod · 0.45
ExistsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…