From d8abdbf5a99cce95678b4447d2da5c45977ad773 Mon Sep 17 00:00:00 2001 From: Niranjan Godbole Date: Sat, 20 May 2017 15:00:04 +0530 Subject: [PATCH] dep init refactor tests --- cmd/dep/integration_test.go | 7 +++---- cmd/dep/remove_test.go | 2 +- internal/test/integration_testcase.go | 24 ++---------------------- internal/test/integration_testproj.go | 25 ------------------------- 4 files changed, 6 insertions(+), 52 deletions(-) diff --git a/cmd/dep/integration_test.go b/cmd/dep/integration_test.go index dccd4097..8e7ce144 100644 --- a/cmd/dep/integration_test.go +++ b/cmd/dep/integration_test.go @@ -109,7 +109,7 @@ func testIntegration(name, wd string, externalProc bool, run test.RunFunc) func( t.Parallel() // Set up environment - testCase := test.NewTestCase(t, name, wd) + testCase := test.NewTestCase(t, name, "harness_tests", wd) defer testCase.Cleanup() testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run) defer testProj.Cleanup() @@ -158,9 +158,9 @@ func testRelativePath(name, wd string, externalProc bool, run test.RunFunc) func t.Parallel() // Set up environment - testCase := test.NewTestCaseRelPath(t, name, wd) + testCase := test.NewTestCase(t, name, "init_path_tests", wd) defer testCase.Cleanup() - testProj := test.NewTestProjectRelPath(t, testCase.InitialPath(), testCase.InitPath, wd, externalProc, run) + testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run) defer testProj.Cleanup() // Create and checkout the vendor revisions @@ -196,7 +196,6 @@ func testRelativePath(name, wd string, externalProc bool, run test.RunFunc) func testCase.CompareFile(dep.ManifestName, testProj.ProjPath(dep.ManifestName)) testCase.CompareFile(dep.LockName, testProj.ProjPath(dep.LockName)) - // Check vendor paths testProj.CompareImportPaths() } } diff --git a/cmd/dep/remove_test.go b/cmd/dep/remove_test.go index 881ccd94..d82e7866 100644 --- a/cmd/dep/remove_test.go +++ b/cmd/dep/remove_test.go @@ -27,7 +27,7 @@ func TestRemoveErrors(t *testing.T) { func removeErrors(name, wd string, externalProc bool, run test.RunFunc) func(*testing.T) { return func(t *testing.T) { - testCase := test.NewTestCase(t, name, wd) + testCase := test.NewTestCase(t, name, "harness_tests", wd) testProj := test.NewTestProject(t, testCase.InitialPath(), wd, externalProc, run) defer testProj.Cleanup() diff --git a/internal/test/integration_testcase.go b/internal/test/integration_testcase.go index ef614d19..f894d156 100644 --- a/internal/test/integration_testcase.go +++ b/internal/test/integration_testcase.go @@ -36,28 +36,8 @@ type IntegrationTestCase struct { InitPath string `json:"init-path"` } -func NewTestCase(t *testing.T, name, wd string) *IntegrationTestCase { - rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", "harness_tests", name)) - n := &IntegrationTestCase{ - t: t, - name: name, - rootPath: rootPath, - initialPath: filepath.Join(rootPath, "initial"), - finalPath: filepath.Join(rootPath, "final"), - } - j, err := ioutil.ReadFile(filepath.Join(rootPath, "testcase.json")) - if err != nil { - panic(err) - } - err = json.Unmarshal(j, n) - if err != nil { - panic(err) - } - return n -} - -func NewTestCaseRelPath(t *testing.T, name, wd string) *IntegrationTestCase { - rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", "init_path_tests", name)) +func NewTestCase(t *testing.T, name, test_dir, wd string) *IntegrationTestCase { + rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", test_dir, name)) n := &IntegrationTestCase{ t: t, name: name, diff --git a/internal/test/integration_testproj.go b/internal/test/integration_testproj.go index b0176c9d..85fbca8b 100644 --- a/internal/test/integration_testproj.go +++ b/internal/test/integration_testproj.go @@ -64,31 +64,6 @@ func NewTestProject(t *testing.T, initPath, wd string, externalProc bool, run Ru return new } -func NewTestProjectRelPath(t *testing.T, initPath, wd, relativePath string, externalProc bool, run RunFunc) *IntegrationTestProject { - new := &IntegrationTestProject{ - t: t, - origWd: wd, - env: os.Environ(), - run: run, - } - new.makeRootTempDir() - new.TempDir(ProjectRoot, "vendor") - new.CopyTree(initPath) - - // Note that the Travis darwin platform, directories with certain roots such - // as /var are actually links to a dirtree under /private. Without the patch - // below the wd, and therefore the GOPATH, is recorded as "/var/..." but the - // actual process runs in "/private/var/..." and dies due to not being in the - // GOPATH because the roots don't line up. - if externalProc && runtime.GOOS == "darwin" && needsPrivateLeader(new.tempdir) { - new.Setenv("GOPATH", filepath.Join("/private", new.tempdir)) - } else { - new.Setenv("GOPATH", new.tempdir) - } - - return new -} - func (p *IntegrationTestProject) Cleanup() { os.RemoveAll(p.tempdir) }