| 1 | |
| 2 | |
| 3 | |
| 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 TestModulesExport(t *testing.T) { |
| 15 | exported := packagestest.Export(t, packagestest.Modules, testdata) |
| 16 | defer exported.Cleanup() |
| 17 | |
| 18 | var expectDir = filepath.Join(exported.Temp(), "fake1") |
| 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", "go.mod", "fake1/go.mod", nil}, |
| 24 | {"golang.org/fake1", "a.go", "fake1/a.go", checkLink("testdata/a.go")}, |
| 25 | {"golang.org/fake1", "b.go", "fake1/b.go", checkContent("package fake1")}, |
| 26 | {"golang.org/fake2", "go.mod", "modcache/pkg/mod/golang.org/fake2@v1.0.0/go.mod", nil}, |
| 27 | {"golang.org/fake2", "other/a.go", "modcache/pkg/mod/golang.org/fake2@v1.0.0/other/a.go", checkContent("package fake2")}, |
| 28 | {"golang.org/fake2/v2", "other/a.go", "modcache/pkg/mod/golang.org/fake2/v2@v2.0.0/other/a.go", checkContent("package fake2")}, |
| 29 | {"golang.org/fake3@v1.1.0", "other/a.go", "modcache/pkg/mod/golang.org/fake3@v1.1.0/other/a.go", checkContent("package fake3")}, |
| 30 | {"golang.org/fake3@v1.0.0", "other/a.go", "modcache/pkg/mod/golang.org/fake3@v1.0.0/other/a.go", nil}, |
| 31 | }) |
| 32 | } |
| 33 | |