summaryrefslogtreecommitdiff
path: root/integration-cli/docker_cli_cp_test.go
diff options
context:
space:
mode:
authorAhmet Alp Balkan <ahmetalpbalkan@gmail.com>2015-02-18 01:55:08 -0800
committerAhmet Alp Balkan <ahmetalpbalkan@gmail.com>2015-02-18 02:27:44 -0800
commitc5b312dcf5efa4f91dee59f4b701ea7a26a6d41e (patch)
tree4ed60d1aa70e25f83677ebebf33cfb7fa11fb99d /integration-cli/docker_cli_cp_test.go
parent2f024bd9e1d0c0ba13e915c486d0c3cd7c2e68bb (diff)
downloaddocker-c5b312dcf5efa4f91dee59f4b701ea7a26a6d41e.tar.gz
integ-cli: Fix path issues in docker cp tests
Some of the `docker cp` tests were using `path/filepath` to craft unix paths. This wouldn't work on Windows since filepath is platform-dependent. Moved code to `path` as much as possible and hacked away some `path/filepath` functionality that doesn't exist in `path` pkg. This fixes the following test cases: - `TestCpGarbagePath` - `TestCpRelativePath` - `TestCpAbsoluteSymlink` - `TestCpSymlinkComponent` Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
Diffstat (limited to 'integration-cli/docker_cli_cp_test.go')
-rw-r--r--integration-cli/docker_cli_cp_test.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/integration-cli/docker_cli_cp_test.go b/integration-cli/docker_cli_cp_test.go
index 7002e1a34a..070b890257 100644
--- a/integration-cli/docker_cli_cp_test.go
+++ b/integration-cli/docker_cli_cp_test.go
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"os/exec"
+ "path"
"path/filepath"
"testing"
)
@@ -57,7 +58,7 @@ func TestCpGarbagePath(t *testing.T) {
tmpname := filepath.Join(tmpdir, cpTestName)
defer os.RemoveAll(tmpdir)
- path := filepath.Join("../../../../../../../../../../../../", cpFullPath)
+ path := path.Join("../../../../../../../../../../../../", cpFullPath)
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
if err != nil {
@@ -120,11 +121,18 @@ func TestCpRelativePath(t *testing.T) {
tmpname := filepath.Join(tmpdir, cpTestName)
defer os.RemoveAll(tmpdir)
- path, _ := filepath.Rel("/", cpFullPath)
+ var relPath string
+ if path.IsAbs(cpFullPath) {
+ // normally this is `filepath.Rel("/", cpFullPath)` but we cannot
+ // get this unix-path manipulation on windows with filepath.
+ relPath = cpFullPath[1:]
+ } else {
+ t.Fatalf("path %s was assumed to be an absolute path", cpFullPath)
+ }
- _, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
+ _, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+relPath, tmpdir)
if err != nil {
- t.Fatalf("couldn't copy from relative path: %s:%s %s", cleanedContainerID, path, err)
+ t.Fatalf("couldn't copy from relative path: %s:%s %s", cleanedContainerID, relPath, err)
}
file, _ := os.Open(tmpname)
@@ -247,7 +255,7 @@ func TestCpAbsoluteSymlink(t *testing.T) {
tmpname := filepath.Join(tmpdir, cpTestName)
defer os.RemoveAll(tmpdir)
- path := filepath.Join("/", "container_path")
+ path := path.Join("/", "container_path")
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
if err != nil {
@@ -311,7 +319,7 @@ func TestCpSymlinkComponent(t *testing.T) {
tmpname := filepath.Join(tmpdir, cpTestName)
defer os.RemoveAll(tmpdir)
- path := filepath.Join("/", "container_path", cpTestName)
+ path := path.Join("/", "container_path", cpTestName)
_, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir)
if err != nil {