зеркало из https://github.com/microsoft/docker.git
make existing tests pass
This commit is contained in:
Родитель
ec9a9a08b8
Коммит
059bb7a262
31
api_test.go
31
api_test.go
|
@ -184,7 +184,7 @@ func TestGetImagesJSON(t *testing.T) {
|
|||
|
||||
found := false
|
||||
for _, img := range images {
|
||||
if img.Repository == unitTestImageName {
|
||||
if strings.Contains(img.RepoTags[0], unitTestImageName) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
@ -275,31 +275,6 @@ func TestGetImagesJSON(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGetImagesViz(t *testing.T) {
|
||||
runtime := mkRuntime(t)
|
||||
defer nuke(runtime)
|
||||
|
||||
srv := &Server{runtime: runtime}
|
||||
|
||||
r := httptest.NewRecorder()
|
||||
if err := getImagesViz(srv, APIVERSION, r, nil, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if r.Code != http.StatusOK {
|
||||
t.Fatalf("%d OK expected, received %d\n", http.StatusOK, r.Code)
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(r.Body)
|
||||
line, err := reader.ReadString('\n')
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if line != "digraph docker {\n" {
|
||||
t.Errorf("Expected digraph docker {\n, %s found", line)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetImagesHistory(t *testing.T) {
|
||||
runtime := mkRuntime(t)
|
||||
defer nuke(runtime)
|
||||
|
@ -1226,7 +1201,7 @@ func TestDeleteImages(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != len(initialImages)+1 {
|
||||
if len(images[0].RepoTags) != len(initialImages[0].RepoTags)+1 {
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images))
|
||||
}
|
||||
|
||||
|
@ -1265,7 +1240,7 @@ func TestDeleteImages(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != len(initialImages) {
|
||||
if len(images[0].RepoTags) != len(initialImages[0].RepoTags) {
|
||||
t.Errorf("Expected %d image, %d found", len(initialImages), len(images))
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != len(initialImages)+3 {
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+2, len(images))
|
||||
if len(images[0].RepoTags) != len(initialImages[0].RepoTags)+3 {
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+3, len(images))
|
||||
}
|
||||
|
||||
if _, err := srv.ImageDelete("utest/docker:tag2", true); err != nil {
|
||||
|
@ -47,7 +47,7 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != len(initialImages)+2 {
|
||||
if len(images[0].RepoTags) != len(initialImages[0].RepoTags)+2 {
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+2, len(images))
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ func TestContainerTagImageDelete(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != len(initialImages)+1 {
|
||||
if len(images[0].RepoTags) != len(initialImages[0].RepoTags)+1 {
|
||||
t.Errorf("Expected %d images, %d found", len(initialImages)+1, len(images))
|
||||
}
|
||||
|
||||
|
@ -462,7 +462,7 @@ func TestRmi(t *testing.T) {
|
|||
if strings.Contains(unitTestImageID, image.ID) {
|
||||
continue
|
||||
}
|
||||
if image.Repository == "" {
|
||||
if image.RepoTags[0] == "<none>:<none>" {
|
||||
t.Fatalf("Expected tagged image, got untagged one.")
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ func TestImagesFilter(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != 2 {
|
||||
if len(images[0].RepoTags) != 2 {
|
||||
t.Fatal("incorrect number of matches returned")
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ func TestImagesFilter(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != 1 {
|
||||
if len(images[0].RepoTags) != 1 {
|
||||
t.Fatal("incorrect number of matches returned")
|
||||
}
|
||||
|
||||
|
@ -508,7 +508,7 @@ func TestImagesFilter(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != 1 {
|
||||
if len(images[0].RepoTags) != 1 {
|
||||
t.Fatal("incorrect number of matches returned")
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ func TestImagesFilter(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(images) != 1 {
|
||||
if len(images[0].RepoTags) != 1 {
|
||||
t.Fatal("incorrect number of matches returned")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package docker
|
|||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestServerListOrderedImagesByCreationDate(t *testing.T) {
|
||||
|
@ -34,29 +35,46 @@ func TestServerListOrderedImagesByCreationDateAndTag(t *testing.T) {
|
|||
runtime := mkRuntime(t)
|
||||
defer nuke(runtime)
|
||||
|
||||
archive, err := fakeTar()
|
||||
err := generateImage("bar", runtime)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
image, err := runtime.graph.Create(archive, nil, "Testing", "", nil)
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
err = generateImage("zed", runtime)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
srv := &Server{runtime: runtime}
|
||||
srv.ContainerTag(image.ID, "repo", "foo", false)
|
||||
srv.ContainerTag(image.ID, "repo", "bar", false)
|
||||
|
||||
images, err := srv.Images(true, "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if images[0].Created != images[1].Created || images[0].Tag >= images[1].Tag {
|
||||
t.Error("Expected []APIImges to be ordered by most recent creation date and tag name.")
|
||||
if images[0].RepoTags[0] != "repo:zed" && images[0].RepoTags[0] != "repo:bar" {
|
||||
t.Errorf("Expected []APIImges to be ordered by most recent creation date. %s", images)
|
||||
}
|
||||
}
|
||||
|
||||
func generateImage(name string, runtime *Runtime) error {
|
||||
|
||||
archive, err := fakeTar()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
image, err := runtime.graph.Create(archive, nil, "Testing", "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
srv := &Server{runtime: runtime}
|
||||
srv.ContainerTag(image.ID, "repo", name, false)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestSortUniquePorts(t *testing.T) {
|
||||
ports := []Port{
|
||||
Port("6379/tcp"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче