diff options
author | Arnaud Porterie <arnaud.porterie@docker.com> | 2015-09-24 10:37:13 -0700 |
---|---|---|
committer | Arnaud Porterie <arnaud.porterie@docker.com> | 2015-09-24 10:37:13 -0700 |
commit | 47b8347fd4ba4aa634f559059d59b6a95e566d7f (patch) | |
tree | 3cd4a50925d61a60965620605a94c9969f965778 | |
parent | de8b5c46ccabf00ce869d3b2a526c32d044653a7 (diff) | |
download | docker-47b8347fd4ba4aa634f559059d59b6a95e566d7f.tar.gz |
Revert "Make 'TestRandomUnixTmpDirPath' platform agnostic"revert-16556-10662-randomunix
-rw-r--r-- | integration-cli/docker_api_containers_test.go | 6 | ||||
-rw-r--r-- | integration-cli/docker_cli_run_test.go | 6 | ||||
-rw-r--r-- | integration-cli/utils.go | 4 | ||||
-rw-r--r-- | pkg/integration/utils.go | 13 | ||||
-rw-r--r-- | pkg/integration/utils_test.go | 8 |
5 files changed, 14 insertions, 23 deletions
diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index 253a699f6d..6814b9d323 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -191,7 +191,7 @@ func (s *DockerSuite) TestContainerApiStartVolumeBinds(c *check.C) { c.Assert(err, check.IsNil) c.Assert(status, check.Equals, http.StatusCreated) - bindPath := randomTmpDirPath("test") + bindPath := randomUnixTmpDirPath("test") config = map[string]interface{}{ "Binds": []string{bindPath + ":/tmp"}, } @@ -222,8 +222,8 @@ func (s *DockerSuite) TestContainerApiStartDupVolumeBinds(c *check.C) { c.Assert(err, check.IsNil) c.Assert(status, check.Equals, http.StatusCreated) - bindPath1 := randomTmpDirPath("test1") - bindPath2 := randomTmpDirPath("test2") + bindPath1 := randomUnixTmpDirPath("test1") + bindPath2 := randomUnixTmpDirPath("test2") config = map[string]interface{}{ "Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"}, diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index e77e12e204..f6fb99b46c 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -322,8 +322,8 @@ func (s *DockerSuite) TestRunNoDupVolumes(c *check.C) { // TODO Windows: This test cannot run on a Windows daemon as Windows does // not support volumes testRequires(c, DaemonIsLinux) - mountstr1 := randomTmpDirPath("test1") + ":/someplace" - mountstr2 := randomTmpDirPath("test2") + ":/someplace" + mountstr1 := randomUnixTmpDirPath("test1") + ":/someplace" + mountstr2 := randomUnixTmpDirPath("test2") + ":/someplace" if out, _, err := dockerCmdWithError("run", "-v", mountstr1, "-v", mountstr2, "busybox", "true"); err == nil { c.Fatal("Expected error about duplicate volume definitions") @@ -2015,7 +2015,7 @@ func (s *DockerSuite) TestVolumesNoCopyData(c *check.C) { c.Fatalf("Data was copied on volumes-from but shouldn't be:\n%q", out) } - tmpDir := randomTmpDirPath("docker_test_bind_mount_copy_data") + tmpDir := randomUnixTmpDirPath("docker_test_bind_mount_copy_data") if out, _, err := dockerCmdWithError("run", "-v", tmpDir+":/foo", "dataimage", "ls", "-lh", "/foo/bar"); err == nil || !strings.Contains(out, "No such file or directory") { c.Fatalf("Data was copied on bind-mount but shouldn't be:\n%q", out) } diff --git a/integration-cli/utils.go b/integration-cli/utils.go index d00a691bb9..064f92f8d0 100644 --- a/integration-cli/utils.go +++ b/integration-cli/utils.go @@ -61,8 +61,8 @@ func listTar(f io.Reader) ([]string, error) { return integration.ListTar(f) } -func randomTmpDirPath(s string) string { - return integration.RandomTmpDirPath(s) +func randomUnixTmpDirPath(s string) string { + return integration.RandomUnixTmpDirPath(s) } func consumeWithSpeed(reader io.Reader, chunkSize int, interval time.Duration, stop chan bool) (n int, err error) { diff --git a/pkg/integration/utils.go b/pkg/integration/utils.go index 9c78cd0ad2..5f81a14d17 100644 --- a/pkg/integration/utils.go +++ b/pkg/integration/utils.go @@ -9,9 +9,8 @@ import ( "io" "os" "os/exec" - "path/filepath" + "path" "reflect" - "runtime" "strings" "syscall" "time" @@ -245,14 +244,10 @@ func ListTar(f io.Reader) ([]string, error) { } } -// RandomTmpDirPath provides a temporary path with rand string appended. +// RandomUnixTmpDirPath provides a temporary unix path with rand string appended. // does not create or checks if it exists. -func RandomTmpDirPath(s string) string { - tmp := "/tmp" - if runtime.GOOS == "windows" { - tmp = os.Getenv("TEMP") - } - return filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) +func RandomUnixTmpDirPath(s string) string { + return path.Join("/tmp", fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10))) } // ConsumeWithSpeed reads chunkSize bytes from reader after every interval. diff --git a/pkg/integration/utils_test.go b/pkg/integration/utils_test.go index 0c0bcebc89..c573b25f3d 100644 --- a/pkg/integration/utils_test.go +++ b/pkg/integration/utils_test.go @@ -6,7 +6,6 @@ import ( "os" "os/exec" "path" - "runtime" "strings" "testing" "time" @@ -342,13 +341,10 @@ func TestListTar(t *testing.T) { } } -func TestRandomTmpDirPath(t *testing.T) { - path := RandomTmpDirPath("something") +func TestRandomUnixTmpDirPath(t *testing.T) { + path := RandomUnixTmpDirPath("something") prefix := "/tmp/something" - if runtime.GOOS == "windows" { - prefix = os.Getenv("TEMP") + `\something` - } expectedSize := len(prefix) + 11 if !strings.HasPrefix(path, prefix) { |