-
Notifications
You must be signed in to change notification settings - Fork 4
/
main_test.go
34 lines (31 loc) · 878 Bytes
/
main_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
package main
import "testing"
var tests = []struct {
wd string
want string
}{
{"/Users/kevin/src/github.com/davecheney/prdeps", "github.com/davecheney/prdeps"},
{"/Users/kevin/src", ""},
{"/Users/kevin/src/1", "1"},
{"/Users/kevin", ""},
{"/Users/kevin/var", ""},
{"/Users/kevin/var/tmp/foo", ""},
{"/Users/blah/src/github.com/davecheney/prdeps", ""},
{"/", ""},
{"", ""},
{"/Users/blah", ""},
}
func TestGetGoSubpath(t *testing.T) {
for _, tt := range tests {
got, err := getGoSubpath("/Users/kevin/src", tt.wd)
if err == nil && got == "" {
t.Errorf("getGoSubpath(%q, %q): want an error, got none", tt.wd, got)
}
if err != nil && got != "" {
t.Errorf("getGoSubpath(%q, %q): want a result, got an error", tt.wd, got)
}
if got != tt.want {
t.Errorf("getGoSubpath(%q, %q): got %t, want %t", "/Users/kevin/src", tt.wd, got, tt.want)
}
}
}