...
1
2
3
4
5 package zip
6
7 import "testing"
8
9 func TestIsVendoredPackage(t *testing.T) {
10 for _, tc := range []struct {
11 path string
12 want bool
13 falsePositive bool
14 }{
15 {path: "vendor/foo/foo.go", want: true},
16 {path: "pkg/vendor/foo/foo.go", want: true},
17 {path: "longpackagename/vendor/foo/foo.go", want: true},
18
19 {path: "vendor/vendor.go", want: false},
20
21
22
23
24 {path: "pkg/vendor/vendor.go", falsePositive: true},
25 {path: "longpackagename/vendor/vendor.go", falsePositive: true},
26 } {
27 got := isVendoredPackage(tc.path)
28 want := tc.want
29 if tc.falsePositive {
30 want = true
31 }
32 if got != want {
33 t.Errorf("isVendoredPackage(%q) = %t; want %t", tc.path, got, tc.want)
34 if tc.falsePositive {
35 t.Logf("(Expected a false-positive due to https://golang.org/issue/37397.)")
36 }
37 }
38 }
39 }
40
View as plain text