1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 func TestIsVendoredPackage(t *testing.T) {
10 for _, tc := range []struct {
13 falsePositive bool // is this case affected by https://golang.org/issue/37397?
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},
19 {path: "vendor/vendor.go", want: false},
21 // We ideally want these cases to be false, but they are affected by
22 // https://golang.org/issue/37397, and if we fix them we will invalidate
23 // existing module checksums. We must leave them as-is-for now.
24 {path: "pkg/vendor/vendor.go", falsePositive: true},
25 {path: "longpackagename/vendor/vendor.go", falsePositive: true},
27 got := isVendoredPackage(tc.path)
33 t.Errorf("isVendoredPackage(%q) = %t; want %t", tc.path, got, tc.want)
35 t.Logf("(Expected a false-positive due to https://golang.org/issue/37397.)")