Debian Codegraph @

internal/xtools-internal/packagestest/gopath_test.go

raw
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 "honnef.co/go/tools/internal/xtools-internal/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 }