From a8ae0aafe36664ce3e28909045f5aff016370035 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Tue, 26 Mar 2013 16:54:13 -0700 Subject: [PATCH] Add unit test for container id format --- container_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/container_test.go b/container_test.go index 3f9b02ab58..fb7cdc2efd 100644 --- a/container_test.go +++ b/container_test.go @@ -7,12 +7,38 @@ import ( "io/ioutil" "math/rand" "os" + "regexp" "sort" "strings" "testing" "time" ) +func TestIdFormat(t *testing.T) { + runtime, err := newTestRuntime() + if err != nil { + t.Fatal(err) + } + defer nuke(runtime) + container1, err := runtime.Create( + &Config{ + Image: GetTestImage(runtime).Id, + Cmd: []string{"/bin/sh", "-c", "echo hello world"}, + Memory: 33554432, + }, + ) + 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 TestCommitRun(t *testing.T) { runtime, err := newTestRuntime() if err != nil {