-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathutil_test.go
37 lines (33 loc) · 847 Bytes
/
util_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
package revealgo
import (
"testing"
)
func TestAddExtention(t *testing.T) {
actual := addExtention("black", "css")
expected := "black.css"
if actual != expected {
t.Errorf("got %v\n want %v", actual, expected)
}
actual = addExtention("white.css", "css")
expected = "white.css"
if actual != expected {
t.Errorf("got %v\n want %v", actual, expected)
}
}
func TestDetectContentType(t *testing.T) {
scenarios := []struct {
path string
expected string
}{
{path: "css/moon.css", expected: "text/css"},
{path: "js/hello.js", expected: "application/javascript"},
{path: "testdata/markdown.svg", expected: "image/svg+xml"},
{path: "readme.txt", expected: ""},
}
for _, s := range scenarios {
actual := detectContentType(s.path)
if actual != s.expected {
t.Errorf("got %v\n want %v", actual, s.expected)
}
}
}