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

Using test names instead of hardcoded ones in integration/image directory

Signed-off-by: Cristina Yenyxe Gonzalez Garcia <cristina.yenyxe@gmail.com>
This commit is contained in:
Cristina Yenyxe Gonzalez Garcia 2020-05-18 16:26:44 +01:00
parent 4cabad6bae
commit 0154dc7a23
4 changed files with 17 additions and 11 deletions

View file

@ -2,6 +2,7 @@ package image // import "github.com/docker/docker/integration/image"
import (
"context"
"strings"
"testing"
"github.com/docker/docker/api/types"
@ -20,10 +21,11 @@ func TestCommitInheritsEnv(t *testing.T) {
ctx := context.Background()
cID1 := container.Create(ctx, t, client)
imgName := strings.ToLower(t.Name())
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
Changes: []string{"ENV PATH=/bin"},
Reference: "test-commit-image",
Reference: imgName,
})
assert.NilError(t, err)
@ -37,7 +39,7 @@ func TestCommitInheritsEnv(t *testing.T) {
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
Changes: []string{"ENV PATH=/usr/bin:$PATH"},
Reference: "test-commit-image",
Reference: imgName,
})
assert.NilError(t, err)

View file

@ -6,6 +6,7 @@ import (
"context"
"io"
"runtime"
"strings"
"testing"
"github.com/docker/docker/api/types"
@ -38,10 +39,11 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) {
err := tw.Close()
assert.NilError(t, err)
imageRdr := io.MultiReader(&tarBuffer, io.LimitReader(testutil.DevZero, 8*1024*1024*1024))
reference := strings.ToLower(t.Name()) + ":v42"
_, err = client.ImageImport(context.Background(),
types.ImageImportSource{Source: imageRdr, SourceName: "-"},
"test1234:v42",
reference,
types.ImageImportOptions{})
assert.NilError(t, err)
}

View file

@ -2,6 +2,7 @@ package image // import "github.com/docker/docker/integration/image"
import (
"context"
"strings"
"testing"
"github.com/docker/docker/api/types"
@ -19,7 +20,7 @@ func TestImagesFilterMultiReference(t *testing.T) {
client := testEnv.APIClient()
ctx := context.Background()
name := "images_filter_multi_reference"
name := strings.ToLower(t.Name())
repoTags := []string{
name + ":v1",
name + ":v2",

View file

@ -2,6 +2,7 @@ package image // import "github.com/docker/docker/integration/image"
import (
"context"
"strings"
"testing"
"github.com/docker/docker/api/types"
@ -17,36 +18,36 @@ func TestRemoveImageOrphaning(t *testing.T) {
ctx := context.Background()
client := testEnv.APIClient()
img := "test-container-orphaning"
imgName := strings.ToLower(t.Name())
// Create a container from busybox, and commit a small change so we have a new image
cID1 := container.Create(ctx, t, client, container.WithCmd(""))
commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
Changes: []string{`ENTRYPOINT ["true"]`},
Reference: img,
Reference: imgName,
})
assert.NilError(t, err)
// verifies that reference now points to first image
resp, _, err := client.ImageInspectWithRaw(ctx, img)
resp, _, err := client.ImageInspectWithRaw(ctx, imgName)
assert.NilError(t, err)
assert.Check(t, is.Equal(resp.ID, commitResp1.ID))
// Create a container from created image, and commit a small change with same reference name
cID2 := container.Create(ctx, t, client, container.WithImage(img), container.WithCmd(""))
cID2 := container.Create(ctx, t, client, container.WithImage(imgName), container.WithCmd(""))
commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
Changes: []string{`LABEL Maintainer="Integration Tests"`},
Reference: img,
Reference: imgName,
})
assert.NilError(t, err)
// verifies that reference now points to second image
resp, _, err = client.ImageInspectWithRaw(ctx, img)
resp, _, err = client.ImageInspectWithRaw(ctx, imgName)
assert.NilError(t, err)
assert.Check(t, is.Equal(resp.ID, commitResp2.ID))
// try to remove the image, should not error out.
_, err = client.ImageRemove(ctx, img, types.ImageRemoveOptions{})
_, err = client.ImageRemove(ctx, imgName, types.ImageRemoveOptions{})
assert.NilError(t, err)
// check if the first image is still there