mirror of https://github.com/docker/docs.git
Move TestRunCidFileCleanupIfEmpty to integration-cli
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
This commit is contained in:
parent
2aaa8892e3
commit
8892320835
|
@ -1772,3 +1772,26 @@ func TestHostsLinkedContainerUpdate(t *testing.T) {
|
||||||
|
|
||||||
logDone("run - /etc/hosts updated in parent when restart")
|
logDone("run - /etc/hosts updated in parent when restart")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that CIDFile gets deleted if it's empty
|
||||||
|
// Perform this test by making `docker run` fail
|
||||||
|
func TestRunCidFileCleanupIfEmpty(t *testing.T) {
|
||||||
|
tmpDir, err := ioutil.TempDir("", "TestRunCidFile")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
tmpCidFile := path.Join(tmpDir, "cid")
|
||||||
|
cmd := exec.Command(dockerBinary, "run", "--cidfile", tmpCidFile, "scratch")
|
||||||
|
out, _, err := runCommandWithOutput(cmd)
|
||||||
|
t.Log(out)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("Run without command must fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(tmpCidFile); err == nil {
|
||||||
|
t.Fatalf("empty CIDFile '%s' should've been deleted", tmpCidFile)
|
||||||
|
}
|
||||||
|
deleteAllContainers()
|
||||||
|
logDone("run - cleanup empty cidfile on fail")
|
||||||
|
}
|
||||||
|
|
|
@ -583,32 +583,3 @@ func TestRunCidFileCheckIDLength(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that CIDFile gets deleted if it's empty
|
|
||||||
// Perform this test by making `docker run` fail
|
|
||||||
func TestRunCidFileCleanupIfEmpty(t *testing.T) {
|
|
||||||
tmpDir, err := ioutil.TempDir("", "TestRunCidFile")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
tmpCidFile := path.Join(tmpDir, "cid")
|
|
||||||
|
|
||||||
cli := client.NewDockerCli(nil, ioutil.Discard, ioutil.Discard, testDaemonProto, testDaemonAddr, nil)
|
|
||||||
defer cleanup(globalEngine, t)
|
|
||||||
|
|
||||||
c := make(chan struct{})
|
|
||||||
go func() {
|
|
||||||
defer close(c)
|
|
||||||
if err := cli.CmdRun("--cidfile", tmpCidFile, unitTestImageID); err == nil {
|
|
||||||
t.Fatal("running without a command should haveve failed")
|
|
||||||
}
|
|
||||||
if _, err := os.Stat(tmpCidFile); err == nil {
|
|
||||||
t.Fatalf("empty CIDFile '%s' should've been deleted", tmpCidFile)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
setTimeout(t, "CmdRun timed out", 5*time.Second, func() {
|
|
||||||
<-c
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue