mirror of https://github.com/perkeep/perkeep.git
osutil: don't use host config during tests
Change-Id: I28171f0dc9c3c21c9693805781275c39ed517d25
This commit is contained in:
parent
8bbe100bbc
commit
99a4ee0fd3
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue