diff --git a/integration/utils.go b/integration/utils.go index 9c78cd0..469f720 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -11,7 +11,6 @@ import ( "os/exec" "path/filepath" "reflect" - "runtime" "strings" "syscall" "time" @@ -247,12 +246,16 @@ func ListTar(f io.Reader) ([]string, error) { // RandomTmpDirPath provides a temporary path with rand string appended. // does not create or checks if it exists. -func RandomTmpDirPath(s string) string { +func RandomTmpDirPath(s string, platform string) string { tmp := "/tmp" - if runtime.GOOS == "windows" { + if platform == "windows" { tmp = os.Getenv("TEMP") } - return filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) + path := filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) + if platform == "windows" { + return filepath.FromSlash(path) // Using \ + } + return filepath.ToSlash(path) // Using / } // ConsumeWithSpeed reads chunkSize bytes from reader after every interval. diff --git a/integration/utils_test.go b/integration/utils_test.go index 0c0bceb..7c5df4e 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -343,7 +343,7 @@ func TestListTar(t *testing.T) { } func TestRandomTmpDirPath(t *testing.T) { - path := RandomTmpDirPath("something") + path := RandomTmpDirPath("something", runtime.GOOS) prefix := "/tmp/something" if runtime.GOOS == "windows" {