make tempfiles in os.TempDir() not $GOROOT

This commit is contained in:
Jimmy Zelinskie 2013-07-21 20:49:17 -04:00
parent db6d8707df
commit 2d40a3ab97

View file

@ -45,9 +45,9 @@ func TestNewConfig(t *testing.T) {
func writeAndOpenJsonTest(t *testing.T, fn string) { func writeAndOpenJsonTest(t *testing.T, fn string) {
expandFn := os.ExpandEnv(fn) expandFn := os.ExpandEnv(fn)
//write json to relative path, clean up // Write JSON to relative path, clean up
tfile, ferr := os.Create(expandFn) tfile, ferr := os.Create(expandFn)
//Remove failure not counted as error // Remove failure not counted as error
defer os.Remove(expandFn) defer os.Remove(expandFn)
if ferr != nil { if ferr != nil {
t.Fatal("Failed to create %s. Error: %v", expandFn, ferr) t.Fatal("Failed to create %s. Error: %v", expandFn, ferr)
@ -71,7 +71,7 @@ func writeAndOpenJsonTest(t *testing.T, fn string) {
} }
} }
//These implcitly require the test program have // These implcitly require the test program have
// read/write/delete file system permissions // read/write/delete file system permissions
func TestOpenCurDir(t *testing.T) { func TestOpenCurDir(t *testing.T) {
if !testing.Short() { if !testing.Short() {
@ -82,7 +82,7 @@ func TestOpenCurDir(t *testing.T) {
} }
func TestOpenAbsEnvPath(t *testing.T) { func TestOpenAbsEnvPath(t *testing.T) {
if !testing.Short() { if !testing.Short() {
writeAndOpenJsonTest(t, "$GOROOT/testConfig.json") writeAndOpenJsonTest(t, os.TempDir()+"testConfig.json")
} else { } else {
t.Log("Write/Read file test skipped") t.Log("Write/Read file test skipped")
} }