1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

remove some mkServerFromEngine

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
Victor Vieux 2014-01-29 20:16:47 +00:00
parent f556cd4186
commit fc2f998822
2 changed files with 10 additions and 11 deletions

View file

@ -61,7 +61,7 @@ func cleanup(eng *engine.Engine, t *testing.T) error {
}
for _, image := range images.Data {
if image.Get("ID") != unitTestImageID {
mkServerFromEngine(eng, t).DeleteImage(image.Get("ID"), false)
eng.Job("image_delete", image.Get("ID")).Run()
}
}
return nil
@ -132,10 +132,11 @@ func setupBaseImage() {
if err := job.Run(); err != nil {
log.Fatalf("Unable to create a runtime for tests: %s", err)
}
srv := mkServerFromEngine(eng, log.New(os.Stderr, "", 0))
job = eng.Job("inspect", unitTestImageName, "image")
img, _ := job.Stdout.AddEnv()
// If the unit test is not found, try to download it.
if img, err := srv.ImageInspect(unitTestImageName); err != nil || img.ID != unitTestImageID {
if err := job.Run(); err != nil || img.Get("id") != unitTestImageID {
// Retrieve the Image
job = eng.Job("pull", unitTestImageName)
job.Stdout.Add(utils.NopWriteCloser(os.Stdout))

View file

@ -1,7 +1,7 @@
package docker
import (
"github.com/dotcloud/docker"
"github.com/dotcloud/docker/engine"
"testing"
"time"
)
@ -9,9 +9,8 @@ import (
func TestServerListOrderedImagesByCreationDate(t *testing.T) {
eng := NewTestEngine(t)
defer mkRuntimeFromEngine(eng, t).Nuke()
srv := mkServerFromEngine(eng, t)
if err := generateImage("", srv); err != nil {
if err := generateImage("", eng); err != nil {
t.Fatal(err)
}
@ -25,16 +24,15 @@ func TestServerListOrderedImagesByCreationDate(t *testing.T) {
func TestServerListOrderedImagesByCreationDateAndTag(t *testing.T) {
eng := NewTestEngine(t)
defer mkRuntimeFromEngine(eng, t).Nuke()
srv := mkServerFromEngine(eng, t)
err := generateImage("bar", srv)
err := generateImage("bar", eng)
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
err = generateImage("zed", srv)
err = generateImage("zed", eng)
if err != nil {
t.Fatal(err)
}
@ -46,12 +44,12 @@ func TestServerListOrderedImagesByCreationDateAndTag(t *testing.T) {
}
}
func generateImage(name string, srv *docker.Server) error {
func generateImage(name string, eng *engine.Engine) error {
archive, err := fakeTar()
if err != nil {
return err
}
job := srv.Eng.Job("import", "-", "repo", name)
job := eng.Job("import", "-", "repo", name)
job.Stdin.Add(archive)
job.SetenvBool("json", true)
return job.Run()