(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func 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 | |
| 99 | func TestFileSystemDelete(t *testing.T) { |
| 100 | dir := createTestDir(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…