From 99a4ee0fd3d9afa30e22036722426d188dd03ad9 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 23 Feb 2014 10:00:45 -0800 Subject: [PATCH] osutil: don't use host config during tests Change-Id: I28171f0dc9c3c21c9693805781275c39ed517d25 --- pkg/osutil/paths_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/osutil/paths_test.go b/pkg/osutil/paths_test.go index 67bb65967..00c5ee6d4 100644 --- a/pkg/osutil/paths_test.go +++ b/pkg/osutil/paths_test.go @@ -19,6 +19,7 @@ package osutil import ( "fmt" "os" + "path/filepath" "testing" ) @@ -60,6 +61,10 @@ func checkOpen(t *testing.T, path string) { func TestOpenCamliIncludeNoFile(t *testing.T) { // Test that error occurs if no such file const notExist = "this_config_doesnt_exist.config" + + defer os.Setenv("CAMLI_CONFIG_DIR", os.Getenv("CAMLI_CONFIG_DIR")) + os.Setenv("CAMLI_CONFIG_DIR", filepath.Join(os.TempDir(), "/x/y/z/not-exist")) + _, e := FindCamliInclude(notExist) if e == nil { t.Errorf("Successfully opened config which doesn't exist: %v", notExist) @@ -102,6 +107,9 @@ func TestOpenCamliIncludePath(t *testing.T) { defer os.Remove("/tmp/" + name) defer os.Setenv("CAMLI_INCLUDE_PATH", "") + defer os.Setenv("CAMLI_CONFIG_DIR", os.Getenv("CAMLI_CONFIG_DIR")) + os.Setenv("CAMLI_CONFIG_DIR", filepath.Join(os.TempDir(), "/x/y/z/not-exist")) + os.Setenv("CAMLI_INCLUDE_PATH", "/tmp") checkOpen(t, name)