github.com/cockroachdb/tools@v0.0.0-20230222021103-a6d27438930d/go/packages/packagestest/gopath_test.go (about) 1 // Copyright 2018 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 packagestest_test 6 7 import ( 8 "path/filepath" 9 "testing" 10 11 "golang.org/x/tools/go/packages/packagestest" 12 ) 13 14 func TestGOPATHExport(t *testing.T) { 15 exported := packagestest.Export(t, packagestest.GOPATH, testdata) 16 defer exported.Cleanup() 17 // Check that the cfg contains all the right bits 18 var expectDir = filepath.Join(exported.Temp(), "fake1", "src") 19 if exported.Config.Dir != expectDir { 20 t.Errorf("Got working directory %v expected %v", exported.Config.Dir, expectDir) 21 } 22 checkFiles(t, exported, []fileTest{ 23 {"golang.org/fake1", "a.go", "fake1/src/golang.org/fake1/a.go", checkLink("testdata/a.go")}, 24 {"golang.org/fake1", "b.go", "fake1/src/golang.org/fake1/b.go", checkContent("package fake1")}, 25 {"golang.org/fake2", "other/a.go", "fake2/src/golang.org/fake2/other/a.go", checkContent("package fake2")}, 26 {"golang.org/fake2/v2", "other/a.go", "fake2_v2/src/golang.org/fake2/v2/other/a.go", checkContent("package fake2")}, 27 }) 28 }