(t *testing.T)
| 92 | } |
| 93 | |
| 94 | func TestResolveFilename(t *testing.T) { |
| 95 | tests := []struct { |
| 96 | name string |
| 97 | headers map[string]string |
| 98 | want string |
| 99 | }{ |
| 100 | { |
| 101 | "from content-type pdf", |
| 102 | map[string]string{"Content-Type": "application/pdf"}, |
| 103 | "download.pdf", |
| 104 | }, |
| 105 | { |
| 106 | "from content-type png", |
| 107 | map[string]string{"Content-Type": "image/png"}, |
| 108 | "download.png", |
| 109 | }, |
| 110 | { |
| 111 | "unknown type", |
| 112 | map[string]string{"Content-Type": "application/octet-stream"}, |
| 113 | "download.bin", |
| 114 | }, |
| 115 | { |
| 116 | "empty content-type", |
| 117 | map[string]string{}, |
| 118 | "download.bin", |
| 119 | }, |
| 120 | } |
| 121 | for _, tt := range tests { |
| 122 | t.Run(tt.name, func(t *testing.T) { |
| 123 | resp := newApiResp([]byte("data"), tt.headers) |
| 124 | got := ResolveFilename(resp) |
| 125 | if got != tt.want { |
| 126 | t.Errorf("ResolveFilename() = %q, want %q", got, tt.want) |
| 127 | } |
| 128 | }) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | func TestMimeToExt_Extended(t *testing.T) { |
| 133 | tests := []struct { |
nothing calls this directly
no test coverage detected