Source file src/mime/type_unix_test.go

     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  	err := loadMimeGlobsFile("testdata/test.types.globs2")
    15  	if err != nil {
    16  		t.Fatal(err)
    17  	}
    18  
    19  	loadMimeFile("testdata/test.types")
    20  }
    21  
    22  func TestTypeByExtensionUNIX(t *testing.T) {
    23  	initMimeUnixTest(t)
    24  	typeTests := map[string]string{
    25  		".T1":  "application/test",
    26  		".t2":  "text/test; charset=utf-8",
    27  		".t3":  "document/test",
    28  		".t4":  "example/test",
    29  		".png": "image/png",
    30  	}
    31  
    32  	for ext, want := range typeTests {
    33  		val := TypeByExtension(ext)
    34  		if val != want {
    35  			t.Errorf("TypeByExtension(%q) = %q, want %q", ext, val, want)
    36  		}
    37  	}
    38  }
    39  

View as plain text