Browse Source

Move TestRunWorkdirExistsAndIsFile to integration-cli

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
Alexandr Morozov 11 years ago
parent
commit
a44f065f17
2 changed files with 11 additions and 19 deletions
  1. 11 0
      integration-cli/docker_cli_run_test.go
  2. 0 19
      integration/commands_test.go

+ 11 - 0
integration-cli/docker_cli_run_test.go

@@ -1481,3 +1481,14 @@ func TestRunCleanupCmdOnEntrypoint(t *testing.T) {
 	}
 	}
 	logDone("run - cleanup cmd on --entrypoint")
 	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")
+}

+ 0 - 19
integration/commands_test.go

@@ -113,25 +113,6 @@ func assertPipe(input, output string, r io.Reader, w io.Writer, count int) error
 	return nil
 	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) {
 func TestRunExit(t *testing.T) {
 	stdin, stdinPipe := io.Pipe()
 	stdin, stdinPipe := io.Pipe()
 	stdout, stdoutPipe := io.Pipe()
 	stdout, stdoutPipe := io.Pipe()