| 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/internal/packagestest" |
| 12 | ) |
| 13 | |
| 14 | func TestModulesExport(t *testing.T) { |
| 15 | exported := packagestest.Export(t, packagestest.Modules, testdata) |
| 16 | defer exported.Cleanup() |
| 17 | // Check that the cfg contains all the right bits |
| 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/[email protected]/go.mod", nil}, |
| 27 | {"golang.org/fake2", "other/a.go", "modcache/pkg/mod/golang.org/[email protected]/other/a.go", checkContent("package fake2")}, |
| 28 | {"golang.org/fake2/v2", "other/a.go", "modcache/pkg/mod/golang.org/fake2/[email protected]/other/a.go", checkContent("package fake2")}, |
| 29 | {"golang.org/[email protected]", "other/a.go", "modcache/pkg/mod/golang.org/[email protected]/other/a.go", checkContent("package fake3")}, |
| 30 | {"golang.org/[email protected]", "other/a.go", "modcache/pkg/mod/golang.org/[email protected]/other/a.go", nil}, |
| 31 | }) |
| 32 | } |