From d00fb4096700cd8feed06ca32c93f080fb6446b1 Mon Sep 17 00:00:00 2001 From: Isao Jonas Date: Mon, 5 Aug 2013 09:03:42 -0500 Subject: [PATCH] added tests for 1405 --- buildfile_test.go | 34 ++++++++++++++++++++++++++++++++++ container_test.go | 22 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/buildfile_test.go b/buildfile_test.go index 0e2d9ecefc..9d002f0665 100644 --- a/buildfile_test.go +++ b/buildfile_test.go @@ -328,6 +328,40 @@ func TestBuildEntrypoint(t *testing.T) { } } +// testing #1405 - config.Cmd does not get cleaned up if +// utilizing cache +func TestBuildEntrypointRunCleanup(t *testing.T) { + runtime, err := newTestRuntime() + if err != nil { + t.Fatal(err) + } + defer nuke(runtime) + + srv := &Server{ + runtime: runtime, + pullingPool: make(map[string]struct{}), + pushingPool: make(map[string]struct{}), + } + + img := buildImage(testContextTemplate{` + from {IMAGE} + run echo "hello" + `, + nil, nil}, t, srv, true) + + img = buildImage(testContextTemplate{` + from {IMAGE} + run echo "hello" + add foo /foo + entrypoint ["/bin/echo"] + `, + [][2]string{{"foo", "HEYO"}}, nil}, t, srv, true) + + if len(img.Config.Cmd) != 0 { + t.Fail() + } +} + func TestBuildImageWithCache(t *testing.T) { runtime, err := newTestRuntime() if err != nil { diff --git a/container_test.go b/container_test.go index f29ae9e4ea..2f9da15f6e 100644 --- a/container_test.go +++ b/container_test.go @@ -996,6 +996,28 @@ func TestEntrypoint(t *testing.T) { } } +func TestEntrypointNoCmd(t *testing.T) { + runtime := mkRuntime(t) + defer nuke(runtime) + container, err := NewBuilder(runtime).Create( + &Config{ + Image: GetTestImage(runtime).ID, + Entrypoint: []string{"/bin/echo", "foobar"}, + }, + ) + if err != nil { + t.Fatal(err) + } + defer runtime.Destroy(container) + output, err := container.Output() + if err != nil { + t.Fatal(err) + } + if strings.Trim(string(output), "\r\n") != "foobar" { + t.Error(string(output)) + } +} + func grepFile(t *testing.T, path string, pattern string) { f, err := os.Open(path) if err != nil {