Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
| ... | ... |
@@ -1481,3 +1481,14 @@ func TestRunCleanupCmdOnEntrypoint(t *testing.T) {
|
| 1481 | 1481 |
} |
| 1482 | 1482 |
logDone("run - cleanup cmd on --entrypoint")
|
| 1483 | 1483 |
} |
| 1484 |
+ |
|
| 1485 |
+// TestRunWorkdirExistsAndIsFile checks that if 'docker run -w' with existing file can be detected |
|
| 1486 |
+func TestRunWorkdirExistsAndIsFile(t *testing.T) {
|
|
| 1487 |
+ defer deleteAllContainers() |
|
| 1488 |
+ runCmd := exec.Command(dockerBinary, "run", "-w", "/bin/cat", "busybox") |
|
| 1489 |
+ out, exit, err := runCommandWithOutput(runCmd) |
|
| 1490 |
+ if !(err != nil && exit == 1 && strings.Contains(out, "Cannot mkdir: /bin/cat is not a directory")) {
|
|
| 1491 |
+ t.Fatalf("Docker must complains about making dir, but we got out: %s, exit: %d, err: %s", out, exit, err)
|
|
| 1492 |
+ } |
|
| 1493 |
+ logDone("run - error on existing file for workdir")
|
|
| 1494 |
+} |
| ... | ... |
@@ -113,25 +113,6 @@ func assertPipe(input, output string, r io.Reader, w io.Writer, count int) error |
| 113 | 113 |
return nil |
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 |
-// TestRunWorkdirExistsAndIsFile checks that if 'docker run -w' with existing file can be detected |
|
| 117 |
-func TestRunWorkdirExistsAndIsFile(t *testing.T) {
|
|
| 118 |
- |
|
| 119 |
- cli := client.NewDockerCli(nil, nil, ioutil.Discard, testDaemonProto, testDaemonAddr, nil) |
|
| 120 |
- defer cleanup(globalEngine, t) |
|
| 121 |
- |
|
| 122 |
- c := make(chan struct{})
|
|
| 123 |
- go func() {
|
|
| 124 |
- defer close(c) |
|
| 125 |
- if err := cli.CmdRun("-w", "/bin/cat", unitTestImageID, "pwd"); err == nil {
|
|
| 126 |
- t.Fatal("should have failed to run when using /bin/cat as working dir.")
|
|
| 127 |
- } |
|
| 128 |
- }() |
|
| 129 |
- |
|
| 130 |
- setTimeout(t, "CmdRun timed out", 5*time.Second, func() {
|
|
| 131 |
- <-c |
|
| 132 |
- }) |
|
| 133 |
-} |
|
| 134 |
- |
|
| 135 | 116 |
func TestRunExit(t *testing.T) {
|
| 136 | 117 |
stdin, stdinPipe := io.Pipe() |
| 137 | 118 |
stdout, stdoutPipe := io.Pipe() |