forked from cespare/deplist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeplist_test.go
40 lines (37 loc) · 888 Bytes
/
deplist_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
package main
import (
"os"
"path/filepath"
"reflect"
"testing"
)
var testCases = []struct {
name string
dir string
o opts
output []string
}{
{"c", "/", 0, nil},
{"b", "/", 0, []string{"c"}},
{"a", "/", 0, []string{"b", "c"}},
{".", "testdata/src/a", 0, []string{"b", "c"}},
{"a", "/", optTestImports, []string{"b", "c", "d"}},
{"a", "/", optStd, []string{"b", "c", "unsafe"}},
{"a", "/", optTestImports | optStd, []string{"b", "c", "d", "unsafe"}},
{"e", "/", 0, []string{"e/vendor/v0", "e/vendor/v0/vendor/a"}},
}
func TestFindDeps(t *testing.T) {
cwd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
for _, tt := range testCases {
deps, err := findDeps(tt.name, tt.dir, filepath.Join(cwd, "testdata"), tt.o)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(deps, tt.output) {
t.Errorf("got %v; want %v\n", deps, tt.output)
}
}
}