| 20 | ) |
| 21 | |
| 22 | func 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 | |
| 57 | func TestFileSystemAttributes(t *testing.T) { |
| 58 | dir := createTestDir(t) |