From 76a19bb3a95ef788cd889b36b0af3b79327ff431 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 18 Apr 2014 01:58:20 +0000 Subject: [PATCH] Add test verify container ID Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- integration-cli/docker_cli_run_test.go | 24 ++++++++++++++++++++++++ integration/container_test.go | 22 ---------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index b0805dd35c..fef7d94984 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os/exec" + "regexp" "strings" "testing" ) @@ -384,3 +385,26 @@ func TestMultipleVolumesFrom(t *testing.T) { logDone("run - multiple volumes from") } + +// this tests verifies the ID format for the container +func TestVerifyContainerID(t *testing.T) { + cmd := exec.Command(dockerBinary, "run", "-d", "busybox", "true") + out, exit, err := runCommandWithOutput(cmd) + if err != nil { + t.Fatal(err) + } + if exit != 0 { + t.Fatalf("expected exit code 0 received %d", exit) + } + match, err := regexp.MatchString("^[0-9a-f]{64}$", strings.TrimSuffix(out, "\n")) + if err != nil { + t.Fatal(err) + } + if !match { + t.Fatalf("Invalid container ID: %s", out) + } + + deleteAllContainers() + + logDone("run - verify container ID") +} diff --git a/integration/container_test.go b/integration/container_test.go index 018d7454cc..40328e89c0 100644 --- a/integration/container_test.go +++ b/integration/container_test.go @@ -16,28 +16,6 @@ import ( "time" ) -func TestIDFormat(t *testing.T) { - daemon := mkDaemon(t) - defer nuke(daemon) - container1, _, err := daemon.Create( - &runconfig.Config{ - Image: GetTestImage(daemon).ID, - Cmd: []string{"/bin/sh", "-c", "echo hello world"}, - }, - "", - ) - if err != nil { - t.Fatal(err) - } - match, err := regexp.Match("^[0-9a-f]{64}$", []byte(container1.ID)) - if err != nil { - t.Fatal(err) - } - if !match { - t.Fatalf("Invalid container ID: %s", container1.ID) - } -} - func TestMultipleAttachRestart(t *testing.T) { daemon := mkDaemon(t) defer nuke(daemon)