github.com/comwrg/go/src@v0.0.0-20220319063731-c238d0440370/mime/type_unix_test.go (about) 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 // +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris 7 8 package mime 9 10 import ( 11 "testing" 12 ) 13 14 func initMimeUnixTest(t *testing.T) { 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 }