...

Source file src/golang.org/x/mod/zip/vendor_test.go

Documentation: golang.org/x/mod/zip

     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.
     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 // is this case affected by https://golang.org/issue/37397?
    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  		// 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},
    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