Skip to content

Commit cb06878

Browse files
committed
Add test for both format parsers
1 parent 1b573c2 commit cb06878

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/mime/type_unix_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package mime
6+
7+
import (
8+
"testing"
9+
)
10+
11+
func initMimeUnixTest() {
12+
err := loadMimeGlobsFile("testdata/test.types.globs2")
13+
if err != nil {
14+
panic(err)
15+
}
16+
17+
loadMimeFile("testdata/test.types")
18+
}
19+
20+
func TestTypeByExtensionUNIX(t *testing.T) {
21+
initMimeUnixTest()
22+
typeTests := map[string]string{
23+
".T1": "application/test",
24+
".t2": "text/test; charset=utf-8",
25+
".png": "image/png",
26+
}
27+
28+
for ext, want := range typeTests {
29+
val := TypeByExtension(ext)
30+
if val != want {
31+
t.Errorf("TypeByExtension(%q) = %q, want %q", ext, val, want)
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)