Browse code

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

Signed-off-by: Cristina Yenyxe Gonzalez Garcia <cristina.yenyxe@gmail.com>

Cristina Yenyxe Gonzalez Garcia authored on 2020/05/19 00:26:44
Showing 4 changed files
... ...
@@ -2,6 +2,7 @@ package image // import "github.com/docker/docker/integration/image"
2 2
 
3 3
 import (
4 4
 	"context"
5
+	"strings"
5 6
 	"testing"
6 7
 
7 8
 	"github.com/docker/docker/api/types"
... ...
@@ -20,10 +21,11 @@ func TestCommitInheritsEnv(t *testing.T) {
20 20
 	ctx := context.Background()
21 21
 
22 22
 	cID1 := container.Create(ctx, t, client)
23
+	imgName := strings.ToLower(t.Name())
23 24
 
24 25
 	commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
25 26
 		Changes:   []string{"ENV PATH=/bin"},
26
-		Reference: "test-commit-image",
27
+		Reference: imgName,
27 28
 	})
28 29
 	assert.NilError(t, err)
29 30
 
... ...
@@ -37,7 +39,7 @@ func TestCommitInheritsEnv(t *testing.T) {
37 37
 
38 38
 	commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
39 39
 		Changes:   []string{"ENV PATH=/usr/bin:$PATH"},
40
-		Reference: "test-commit-image",
40
+		Reference: imgName,
41 41
 	})
42 42
 	assert.NilError(t, err)
43 43
 
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"context"
7 7
 	"io"
8 8
 	"runtime"
9
+	"strings"
9 10
 	"testing"
10 11
 
11 12
 	"github.com/docker/docker/api/types"
... ...
@@ -38,10 +39,11 @@ func TestImportExtremelyLargeImageWorks(t *testing.T) {
38 38
 	err := tw.Close()
39 39
 	assert.NilError(t, err)
40 40
 	imageRdr := io.MultiReader(&tarBuffer, io.LimitReader(testutil.DevZero, 8*1024*1024*1024))
41
+	reference := strings.ToLower(t.Name()) + ":v42"
41 42
 
42 43
 	_, err = client.ImageImport(context.Background(),
43 44
 		types.ImageImportSource{Source: imageRdr, SourceName: "-"},
44
-		"test1234:v42",
45
+		reference,
45 46
 		types.ImageImportOptions{})
46 47
 	assert.NilError(t, err)
47 48
 }
... ...
@@ -2,6 +2,7 @@ package image // import "github.com/docker/docker/integration/image"
2 2
 
3 3
 import (
4 4
 	"context"
5
+	"strings"
5 6
 	"testing"
6 7
 
7 8
 	"github.com/docker/docker/api/types"
... ...
@@ -19,7 +20,7 @@ func TestImagesFilterMultiReference(t *testing.T) {
19 19
 	client := testEnv.APIClient()
20 20
 	ctx := context.Background()
21 21
 
22
-	name := "images_filter_multi_reference"
22
+	name := strings.ToLower(t.Name())
23 23
 	repoTags := []string{
24 24
 		name + ":v1",
25 25
 		name + ":v2",
... ...
@@ -2,6 +2,7 @@ package image // import "github.com/docker/docker/integration/image"
2 2
 
3 3
 import (
4 4
 	"context"
5
+	"strings"
5 6
 	"testing"
6 7
 
7 8
 	"github.com/docker/docker/api/types"
... ...
@@ -17,36 +18,36 @@ func TestRemoveImageOrphaning(t *testing.T) {
17 17
 	ctx := context.Background()
18 18
 	client := testEnv.APIClient()
19 19
 
20
-	img := "test-container-orphaning"
20
+	imgName := strings.ToLower(t.Name())
21 21
 
22 22
 	// Create a container from busybox, and commit a small change so we have a new image
23 23
 	cID1 := container.Create(ctx, t, client, container.WithCmd(""))
24 24
 	commitResp1, err := client.ContainerCommit(ctx, cID1, types.ContainerCommitOptions{
25 25
 		Changes:   []string{`ENTRYPOINT ["true"]`},
26
-		Reference: img,
26
+		Reference: imgName,
27 27
 	})
28 28
 	assert.NilError(t, err)
29 29
 
30 30
 	// verifies that reference now points to first image
31
-	resp, _, err := client.ImageInspectWithRaw(ctx, img)
31
+	resp, _, err := client.ImageInspectWithRaw(ctx, imgName)
32 32
 	assert.NilError(t, err)
33 33
 	assert.Check(t, is.Equal(resp.ID, commitResp1.ID))
34 34
 
35 35
 	// Create a container from created image, and commit a small change with same reference name
36
-	cID2 := container.Create(ctx, t, client, container.WithImage(img), container.WithCmd(""))
36
+	cID2 := container.Create(ctx, t, client, container.WithImage(imgName), container.WithCmd(""))
37 37
 	commitResp2, err := client.ContainerCommit(ctx, cID2, types.ContainerCommitOptions{
38 38
 		Changes:   []string{`LABEL Maintainer="Integration Tests"`},
39
-		Reference: img,
39
+		Reference: imgName,
40 40
 	})
41 41
 	assert.NilError(t, err)
42 42
 
43 43
 	// verifies that reference now points to second image
44
-	resp, _, err = client.ImageInspectWithRaw(ctx, img)
44
+	resp, _, err = client.ImageInspectWithRaw(ctx, imgName)
45 45
 	assert.NilError(t, err)
46 46
 	assert.Check(t, is.Equal(resp.ID, commitResp2.ID))
47 47
 
48 48
 	// try to remove the image, should not error out.
49
-	_, err = client.ImageRemove(ctx, img, types.ImageRemoveOptions{})
49
+	_, err = client.ImageRemove(ctx, imgName, types.ImageRemoveOptions{})
50 50
 	assert.NilError(t, err)
51 51
 
52 52
 	// check if the first image is still there