From 87e8d7754e218d93b480b94537d07793f6680515 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 22 Apr 2014 19:24:47 -0700 Subject: [PATCH] Update tests with engine root removal Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- api/server/server_unit_test.go | 14 +------------- integration/runtime_test.go | 7 ++++--- integration/utils_test.go | 1 + 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/api/server/server_unit_test.go b/api/server/server_unit_test.go index 561f47d343..2dcd0df790 100644 --- a/api/server/server_unit_test.go +++ b/api/server/server_unit_test.go @@ -6,11 +6,9 @@ import ( "fmt" "github.com/dotcloud/docker/api" "github.com/dotcloud/docker/engine" - "github.com/dotcloud/docker/utils" "io" "net/http" "net/http/httptest" - "os" "testing" ) @@ -60,7 +58,6 @@ func TesthttpError(t *testing.T) { func TestGetVersion(t *testing.T) { eng := tmpEngine(t) - defer rmEngine(eng) var called bool eng.Register("version", func(job *engine.Job) engine.Status { called = true @@ -90,7 +87,6 @@ func TestGetVersion(t *testing.T) { func TestGetInfo(t *testing.T) { eng := tmpEngine(t) - defer rmEngine(eng) var called bool eng.Register("info", func(job *engine.Job) engine.Status { called = true @@ -131,21 +127,13 @@ func serveRequest(method, target string, body io.Reader, eng *engine.Engine, t * } func tmpEngine(t *testing.T) *engine.Engine { - tmp, err := utils.TestDirectory("") - if err != nil { - t.Fatal(err) - } - eng, err := engine.New(tmp) + eng, err := engine.New() if err != nil { t.Fatal(err) } return eng } -func rmEngine(eng *engine.Engine) { - os.RemoveAll(eng.Root()) -} - func readEnv(src io.Reader, t *testing.T) *engine.Env { out := engine.NewOutput() v, err := out.AddEnv() diff --git a/integration/runtime_test.go b/integration/runtime_test.go index 497d1c51c8..bf00437547 100644 --- a/integration/runtime_test.go +++ b/integration/runtime_test.go @@ -627,9 +627,10 @@ func TestRestore(t *testing.T) { // Here are are simulating a docker restart - that is, reloading all containers // from scratch - eng = newTestEngine(t, false, runtime.Config().Root) - if len(runtime2.List()) != 2 { - t.Errorf("Expected 2 container, %v found", len(runtime2.List())) + eng = newTestEngine(t, false, daemon1.Config().Root) + daemon2 := mkDaemonFromEngine(eng, t) + if len(daemon2.List()) != 2 { + t.Errorf("Expected 2 container, %v found", len(daemon2.List())) } runningCount := 0 for _, c := range daemon2.List() { diff --git a/integration/utils_test.go b/integration/utils_test.go index 6e2b8abc9e..f455657705 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -181,6 +181,7 @@ func newTestEngine(t utils.Fataler, autorestart bool, root string) *engine.Engin root = dir } } + os.MkdirAll(root, 0700) eng, err := engine.New() if err != nil { t.Fatal(err)