mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-08 06:51:40 +00:00
Move TestRunCidFileCheckIDLength to integration-cli
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
This commit is contained in:
@@ -1795,3 +1795,34 @@ func TestRunCidFileCleanupIfEmpty(t *testing.T) {
|
||||
deleteAllContainers()
|
||||
logDone("run - cleanup empty cidfile on fail")
|
||||
}
|
||||
|
||||
// #2098 - Docker cidFiles only contain short version of the containerId
|
||||
//sudo docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
|
||||
// TestRunCidFile tests that run --cidfile returns the longid
|
||||
func TestRunCidFileCheckIDLength(t *testing.T) {
|
||||
tmpDir, err := ioutil.TempDir("", "TestRunCidFile")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tmpCidFile := path.Join(tmpDir, "cid")
|
||||
defer os.RemoveAll(tmpDir)
|
||||
cmd := exec.Command(dockerBinary, "run", "-d", "--cidfile", tmpCidFile, "busybox", "true")
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
id := strings.TrimSpace(out)
|
||||
buffer, err := ioutil.ReadFile(tmpCidFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cid := string(buffer)
|
||||
if len(cid) != 64 {
|
||||
t.Fatalf("--cidfile should be a long id, not '%s'", id)
|
||||
}
|
||||
if cid != id {
|
||||
t.Fatalf("cid must be equal to %s, got %s", id, cid)
|
||||
}
|
||||
deleteAllContainers()
|
||||
logDone("run - cidfile contains long id")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user