-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutils_test.go
61 lines (55 loc) · 1.45 KB
/
utils_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package wildcat
import "testing"
func TestIsUrl(t *testing.T) {
testdata := []struct {
giveString string
wontURL bool
}{
{"http://github.com/tamada", true},
{"github.com/tamada", false},
{"/hoge/path", false},
{"https://github.com/tamada", true},
}
for _, td := range testdata {
gotFlag := IsURL(td.giveString)
if gotFlag != td.wontURL {
t.Errorf(`IsUrl("%s") did not match, wont %v, got %v`, td.giveString, td.wontURL, gotFlag)
}
}
}
func TestExistFile(t *testing.T) {
testdata := []struct {
givePath string
wontFlag bool
}{
{"testdata/wc/humpty_dumpty.txt", true},
{"testdata/wc/london_bridge_is_broken_down.txt", true},
{"testdata/wc/ja/sakura_sakura.txt", true},
{"testdata", false},
{"no_file_or_directory", false},
}
for _, td := range testdata {
gotFlag := ExistFile(td.givePath)
if gotFlag != td.wontFlag {
t.Errorf("ExistFile(%s) did not match, wont %v, got %v", td.givePath, td.wontFlag, gotFlag)
}
}
}
func TestExistDir(t *testing.T) {
testdata := []struct {
givePath string
wontFlag bool
}{
{"testdata/wc/humpty_dumpty.txt", false},
{"testdata/wc/london_bridge_is_broken_down.txt", false},
{"testdata/wc/ja/sakura_sakura.txt", false},
{"testdata", true},
{"no_file_or_directory", false},
}
for _, td := range testdata {
gotFlag := ExistDir(td.givePath)
if gotFlag != td.wontFlag {
t.Errorf("ExistFile(%s) did not match, wont %v, got %v", td.givePath, td.wontFlag, gotFlag)
}
}
}