Update tests with engine root removal

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
Michael Crosby 2014-04-22 19:24:47 -07:00
parent 672edfe807
commit 87e8d7754e
3 changed files with 6 additions and 16 deletions

View file

@ -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()

View file

@ -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() {

View file

@ -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)