-
Notifications
You must be signed in to change notification settings - Fork 3
/
magic_test.go
47 lines (38 loc) · 964 Bytes
/
magic_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// This file is subject to a 1-clause BSD license.
// Its contents can be found in the enclosed LICENSE file.
package magic
import (
"strings"
"testing"
)
var magic_files = [...]string{
"testdata/compiled/archives.mgc",
"testdata/compiled/bootloaders.mgc",
"testdata/compiled/compressed.mgc",
"testdata/compiled/crypto.mgc",
"testdata/compiled/executables.mgc",
"testdata/compiled/filesystems.mgc",
"testdata/compiled/firmware.mgc",
"testdata/compiled/kernels.mgc",
"testdata/compiled/sql.mgc",
}
func Test(t *testing.T) {
conn, err := Open(FlagMime)
if err != nil {
t.Fatal(err)
}
defer conn.Close()
err = conn.Load(strings.Join(magic_files[:], ":"))
if err != nil {
t.Fatal(err)
}
const want = "text/plain; charset=us-ascii"
// Test mimetype for this source file.
have, err := conn.File("magic_test.go")
if err != nil {
t.Fatal(err)
}
if have != want {
t.Fatalf("Unexpected mime type. Want %q, have %q", want, have)
}
}