Move sorter_test from integration to integration-cli

TestServerListOrderedImagesByCreationDateAndTag was redundant and broken
Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
This commit is contained in:
LK4D4 2014-06-23 22:19:52 +04:00
Родитель fa8f89c521
Коммит 386d1ecc6e
2 изменённых файлов: 42 добавлений и 56 удалений

Просмотреть файл

@ -5,6 +5,7 @@ import (
"os/exec"
"strings"
"testing"
"time"
)
func TestImagesEnsureImageIsListed(t *testing.T) {
@ -56,3 +57,44 @@ func TestCLIImageTagRemove(t *testing.T) {
}
logDone("tag,rmi- tagging the same images multiple times then removing tags")
}
func TestImagesOrderedByCreationDate(t *testing.T) {
defer deleteImages("order:test_a")
defer deleteImages("order:test_c")
defer deleteImages("order:test_b")
id1, err := buildImage("order:test_a",
`FROM scratch
MAINTAINER dockerio1`, true)
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
id2, err := buildImage("order:test_c",
`FROM scratch
MAINTAINER dockerio2`, true)
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
id3, err := buildImage("order:test_b",
`FROM scratch
MAINTAINER dockerio3`, true)
if err != nil {
t.Fatal(err)
}
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "images", "-q", "--no-trunc"))
errorOut(err, t, fmt.Sprintf("listing images failed with errors: %v", err))
imgs := strings.Split(out, "\n")
if imgs[0] != id3 {
t.Fatalf("First image must be %s, got %s", id3, imgs[0])
}
if imgs[1] != id2 {
t.Fatalf("Second image must be %s, got %s", id2, imgs[1])
}
if imgs[2] != id1 {
t.Fatalf("Third image must be %s, got %s", id1, imgs[2])
}
logDone("images - ordering by creation date")
}

Просмотреть файл

@ -1,56 +0,0 @@
package docker
import (
"github.com/dotcloud/docker/engine"
"testing"
"time"
)
func TestServerListOrderedImagesByCreationDate(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
if err := generateImage("", eng); err != nil {
t.Fatal(err)
}
images := getImages(eng, t, true, "")
if images.Data[0].GetInt("Created") < images.Data[1].GetInt("Created") {
t.Error("Expected images to be ordered by most recent creation date.")
}
}
func TestServerListOrderedImagesByCreationDateAndTag(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
err := generateImage("bar", eng)
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Second)
err = generateImage("zed", eng)
if err != nil {
t.Fatal(err)
}
images := getImages(eng, t, true, "")
if repoTags := images.Data[0].GetList("RepoTags"); repoTags[0] != "repo:zed" && repoTags[0] != "repo:bar" {
t.Errorf("Expected Images to be ordered by most recent creation date.")
}
}
func generateImage(name string, eng *engine.Engine) error {
archive, err := fakeTar()
if err != nil {
return err
}
job := eng.Job("import", "-", "repo", name)
job.Stdin.Add(archive)
job.SetenvBool("json", true)
return job.Run()
}