From aa8ea84d11ccac8f68fa1b0337633dd7d49a44fe Mon Sep 17 00:00:00 2001 From: Louis Opter Date: Thu, 27 Jun 2013 17:52:47 -0700 Subject: [PATCH 1/2] Fix a nil dereference in buildfile_test.go The test runtime object wasn't properly initialized. --- buildfile_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/buildfile_test.go b/buildfile_test.go index 1b3eb58182..e64b108660 100644 --- a/buildfile_test.go +++ b/buildfile_test.go @@ -2,6 +2,7 @@ package docker import ( "io/ioutil" + "sync" "testing" ) @@ -92,7 +93,12 @@ func TestBuild(t *testing.T) { } defer nuke(runtime) - srv := &Server{runtime: runtime} + srv := &Server{ + runtime: runtime, + lock: &sync.Mutex{}, + pullingPool: make(map[string]struct{}), + pushingPool: make(map[string]struct{}), + } buildfile := NewBuildFile(srv, ioutil.Discard) if _, err := buildfile.Build(mkTestContext(ctx.dockerfile, ctx.files, t)); err != nil { From fe014a8e6cfe4d2a338736e4c685bcf1b7685200 Mon Sep 17 00:00:00 2001 From: Louis Opter Date: Thu, 27 Jun 2013 17:53:57 -0700 Subject: [PATCH 2/2] Always return the correct test image. And not a *random* one from its history. --- runtime_test.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runtime_test.go b/runtime_test.go index 61a8f346f7..f6235e8c56 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -135,10 +135,13 @@ func GetTestImage(runtime *Runtime) *Image { imgs, err := runtime.graph.All() if err != nil { panic(err) - } else if len(imgs) < 1 { - panic("GASP") } - return imgs[0] + for i := range imgs { + if imgs[i].ID == unitTestImageId { + return imgs[i] + } + } + panic(fmt.Errorf("Test image %v not found", unitTestImageId)) } func TestRuntimeCreate(t *testing.T) {