зеркало из https://github.com/microsoft/docker.git
Add test verify container ID
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Родитель
b84de10b85
Коммит
76a19bb3a9
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
@ -384,3 +385,26 @@ func TestMultipleVolumesFrom(t *testing.T) {
|
||||||
|
|
||||||
logDone("run - multiple volumes from")
|
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")
|
||||||
|
}
|
||||||
|
|
|
@ -16,28 +16,6 @@ import (
|
||||||
"time"
|
"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) {
|
func TestMultipleAttachRestart(t *testing.T) {
|
||||||
daemon := mkDaemon(t)
|
daemon := mkDaemon(t)
|
||||||
defer nuke(daemon)
|
defer nuke(daemon)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче