Debian Codegraph @

libgo/go/mime/type_unix_test.go

raw
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 //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris
6
7 package mime
8
9 import (
10 "testing"
11 )
12
13 func initMimeUnixTest(t *testing.T) {
14 once.Do(initMime)
15 err := loadMimeGlobsFile("testdata/test.types.globs2")
16 if err != nil {
17 t.Fatal(err)
18 }
19
20 loadMimeFile("testdata/test.types")
21 }
22
23 func TestTypeByExtensionUNIX(t *testing.T) {
24 initMimeUnixTest(t)
25 typeTests := map[string]string{
26 ".T1": "application/test",
27 ".t2": "text/test; charset=utf-8",
28 ".t3": "document/test",
29 ".t4": "example/test",
30 ".png": "image/png",
31 }
32
33 for ext, want := range typeTests {
34 val := TypeByExtension(ext)
35 if val != want {
36 t.Errorf("TypeByExtension(%q) = %q, want %q", ext, val, want)
37 }
38 }
39 }