diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 4f004fac13..8bd67f4745 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -1481,3 +1481,14 @@ func TestRunCleanupCmdOnEntrypoint(t *testing.T) { } logDone("run - cleanup cmd on --entrypoint") } + +// TestRunWorkdirExistsAndIsFile checks that if 'docker run -w' with existing file can be detected +func TestRunWorkdirExistsAndIsFile(t *testing.T) { + defer deleteAllContainers() + runCmd := exec.Command(dockerBinary, "run", "-w", "/bin/cat", "busybox") + out, exit, err := runCommandWithOutput(runCmd) + if !(err != nil && exit == 1 && strings.Contains(out, "Cannot mkdir: /bin/cat is not a directory")) { + t.Fatalf("Docker must complains about making dir, but we got out: %s, exit: %d, err: %s", out, exit, err) + } + logDone("run - error on existing file for workdir") +} diff --git a/integration/commands_test.go b/integration/commands_test.go index 44e77e1c7e..0212fdd6d4 100644 --- a/integration/commands_test.go +++ b/integration/commands_test.go @@ -113,25 +113,6 @@ func assertPipe(input, output string, r io.Reader, w io.Writer, count int) error return nil } -// TestRunWorkdirExistsAndIsFile checks that if 'docker run -w' with existing file can be detected -func TestRunWorkdirExistsAndIsFile(t *testing.T) { - - cli := client.NewDockerCli(nil, nil, ioutil.Discard, testDaemonProto, testDaemonAddr, nil) - defer cleanup(globalEngine, t) - - c := make(chan struct{}) - go func() { - defer close(c) - if err := cli.CmdRun("-w", "/bin/cat", unitTestImageID, "pwd"); err == nil { - t.Fatal("should have failed to run when using /bin/cat as working dir.") - } - }() - - setTimeout(t, "CmdRun timed out", 5*time.Second, func() { - <-c - }) -} - func TestRunExit(t *testing.T) { stdin, stdinPipe := io.Pipe() stdout, stdoutPipe := io.Pipe()