main pico / pkg / shared / mime / mime_test.go
sean0407  ·  2026-10-11
 1package mime
 2
 3import "testing"
 4
 5func TestGetMimeType(t *testing.T) {
 6	tests := []struct {
 7		name string
 8		path string
 9		want string
10	}{
11		{name: "binary", path: "archive.bin", want: "application/octet-stream"},
12		{name: "binary_extension_is_case_insensitive", path: "archive.BIN", want: "application/octet-stream"},
13		{name: "unknown_extension_fallback", path: "archive.unknown", want: "text/plain"},
14	}
15
16	for _, tt := range tests {
17		t.Run(tt.name, func(t *testing.T) {
18			if got := GetMimeType(tt.path); got != tt.want {
19				t.Errorf("GetMimeType(%q) = %q, want %q", tt.path, got, tt.want)
20			}
21		})
22	}
23}