From a4cbceb5e84b49099f3b1968ed4232e7c403ed58 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Sat, 2 Dec 2017 11:56:56 +0530 Subject: [PATCH] create default cachedir for tests --- cmd/dep/ensure_test.go | 3 +++ cmd/dep/gopath_scanner_test.go | 3 +++ cmd/dep/status_test.go | 3 +++ internal/importers/importertest/testcase.go | 3 +++ internal/test/integration/testproj.go | 2 ++ manifest_test.go | 3 +++ test_project_context_test.go | 2 ++ 7 files changed, 19 insertions(+) diff --git a/cmd/dep/ensure_test.go b/cmd/dep/ensure_test.go index 2ff439a6dc..85315c1911 100644 --- a/cmd/dep/ensure_test.go +++ b/cmd/dep/ensure_test.go @@ -10,6 +10,7 @@ import ( "go/build" "io/ioutil" "log" + "path/filepath" "strings" "testing" @@ -200,6 +201,8 @@ func TestValidateUpdateArgs(t *testing.T) { h.TempDir("src") pwd := h.Path(".") + // Create the directory for default cachedir location. + h.TempDir(filepath.Join("pkg", "dep")) stderrOutput := &bytes.Buffer{} errLogger := log.New(stderrOutput, "", 0) diff --git a/cmd/dep/gopath_scanner_test.go b/cmd/dep/gopath_scanner_test.go index bfab02e823..b58deb8e18 100644 --- a/cmd/dep/gopath_scanner_test.go +++ b/cmd/dep/gopath_scanner_test.go @@ -7,6 +7,7 @@ package main import ( "io/ioutil" "log" + "path/filepath" "reflect" "testing" @@ -22,6 +23,8 @@ const testProject2 string = "github.com/sdboyer/deptestdos" func NewTestContext(h *test.Helper) *dep.Ctx { h.TempDir("src") pwd := h.Path(".") + // Create the directory for default cachedir location. + h.TempDir(filepath.Join("pkg", "dep")) discardLogger := log.New(ioutil.Discard, "", 0) return &dep.Ctx{ diff --git a/cmd/dep/status_test.go b/cmd/dep/status_test.go index 6f0eb3f4d0..70c5f7c84b 100644 --- a/cmd/dep/status_test.go +++ b/cmd/dep/status_test.go @@ -8,6 +8,7 @@ import ( "bytes" "io/ioutil" "log" + "path/filepath" "reflect" "testing" "text/tabwriter" @@ -384,6 +385,8 @@ func TestCollectConstraints(t *testing.T) { h.TempDir("src") pwd := h.Path(".") + // Create the directory for default cachedir location. + h.TempDir(filepath.Join("pkg", "dep")) discardLogger := log.New(ioutil.Discard, "", 0) ctx := &dep.Ctx{ diff --git a/internal/importers/importertest/testcase.go b/internal/importers/importertest/testcase.go index 0d629531ec..4338fc9929 100644 --- a/internal/importers/importertest/testcase.go +++ b/internal/importers/importertest/testcase.go @@ -8,6 +8,7 @@ import ( "bytes" "io/ioutil" "log" + "path/filepath" "sort" "strings" "testing" @@ -35,6 +36,8 @@ type TestCase struct { func NewTestContext(h *test.Helper) *dep.Ctx { h.TempDir("src") pwd := h.Path(".") + // Create the directory for default cachedir location. + h.TempDir(filepath.Join("pkg", "dep")) discardLogger := log.New(ioutil.Discard, "", 0) return &dep.Ctx{ diff --git a/internal/test/integration/testproj.go b/internal/test/integration/testproj.go index 760e1cc52d..6cce74a3f0 100644 --- a/internal/test/integration/testproj.go +++ b/internal/test/integration/testproj.go @@ -53,6 +53,8 @@ func NewTestProject(t *testing.T, initPath, wd string, run RunFunc) *TestProject new.CopyTree(initPath) new.Setenv("GOPATH", new.tempdir) + // Create the directory for default cachedir location. + new.TempDir("pkg", "dep") return new } diff --git a/manifest_test.go b/manifest_test.go index 93eb95ab83..f1481146e5 100644 --- a/manifest_test.go +++ b/manifest_test.go @@ -10,6 +10,7 @@ import ( "fmt" "io/ioutil" "log" + "path/filepath" "reflect" "strings" "testing" @@ -562,6 +563,8 @@ func TestValidateProjectRoots(t *testing.T) { h.TempDir("src") pwd := h.Path(".") + // Create the directory for default cachedir location. + h.TempDir(filepath.Join("pkg", "dep")) // Capture the stderr to verify the warnings stderrOutput := &bytes.Buffer{} diff --git a/test_project_context_test.go b/test_project_context_test.go index c8ab6692ed..cdf0431f50 100644 --- a/test_project_context_test.go +++ b/test_project_context_test.go @@ -30,6 +30,8 @@ func NewTestProjectContext(h *test.Helper, projectName string) *TestProjectConte // Create the test project directory pc.tempProjectDir = filepath.Join("src", projectName) h.TempDir(pc.tempProjectDir) + // Create the directory for default cachedir location. + h.TempDir(filepath.Join(pc.tempDir, "pkg", "dep")) pc.tempDir = h.Path(".") pc.Project = &Project{AbsRoot: filepath.Join(pc.tempDir, pc.tempProjectDir)} h.Cd(pc.Project.AbsRoot)