(t *testing.T)
| 63 | } |
| 64 | |
| 65 | func TestMagic(t *testing.T) { |
| 66 | var hasFile bool |
| 67 | if _, err := exec.LookPath("file"); err == nil { |
| 68 | hasFile = true |
| 69 | } |
| 70 | |
| 71 | for i, tt := range tests { |
| 72 | var err error |
| 73 | data := []byte(tt.data) |
| 74 | if tt.fileName != "" { |
| 75 | data, err = os.ReadFile("testdata/" + tt.fileName) |
| 76 | if err != nil { |
| 77 | t.Fatalf("Error reading %s: %v", tt.fileName, |
| 78 | err) |
| 79 | } |
| 80 | } |
| 81 | mime := MIMEType(data) |
| 82 | if mime != tt.want { |
| 83 | t.Errorf("%d. got %q; want %q", i, mime, tt.want) |
| 84 | } |
| 85 | if !hasFile { |
| 86 | continue |
| 87 | } |
| 88 | fmime, ok := runFileCmd(data) |
| 89 | if ok && fmime != tt.want { |
| 90 | t.Logf("%d. warning: got %q via file; want %q", i, fmime, tt.want) |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | func TestIsVideoFilename(t *testing.T) { |
| 96 | for _, tt := range tests { |
nothing calls this directly
no test coverage detected