From ebd025b63a1af13092da9cea3731f2ec892128bb Mon Sep 17 00:00:00 2001 From: Cristina Yenyxe Gonzalez Garcia Date: Mon, 18 May 2020 13:42:29 +0100 Subject: [PATCH] Using test names instead of hardcoded ones in integration/build directory Signed-off-by: Cristina Yenyxe Gonzalez Garcia --- integration/build/build_squash_test.go | 2 +- integration/build/build_test.go | 19 ++++++++++--------- ... => Dockerfile.TestBuildPreserveOwnership} | 0 3 files changed, 11 insertions(+), 10 deletions(-) rename integration/build/testdata/{Dockerfile.testBuildPreserveOwnership => Dockerfile.TestBuildPreserveOwnership} (100%) diff --git a/integration/build/build_squash_test.go b/integration/build/build_squash_test.go index 7cacb8253b..54227b0c57 100644 --- a/integration/build/build_squash_test.go +++ b/integration/build/build_squash_test.go @@ -48,7 +48,7 @@ func TestBuildSquashParent(t *testing.T) { source := fakecontext.New(t, "", fakecontext.WithDockerfile(dockerfile)) defer source.Close() - name := "test" + name := strings.ToLower(t.Name()) resp, err := client.ImageBuild(ctx, source.AsTarReader(t), types.ImageBuildOptions{ diff --git a/integration/build/build_test.go b/integration/build/build_test.go index 1ad3159edf..edbfb37935 100644 --- a/integration/build/build_test.go +++ b/integration/build/build_test.go @@ -207,19 +207,20 @@ func TestBuildMultiStageParentConfig(t *testing.T) { defer source.Close() apiclient := testEnv.APIClient() + imgName := strings.ToLower(t.Name()) resp, err := apiclient.ImageBuild(ctx, source.AsTarReader(t), types.ImageBuildOptions{ Remove: true, ForceRemove: true, - Tags: []string{"build1"}, + Tags: []string{imgName}, }) assert.NilError(t, err) _, err = io.Copy(ioutil.Discard, resp.Body) resp.Body.Close() assert.NilError(t, err) - image, _, err := apiclient.ImageInspectWithRaw(ctx, "build1") + image, _, err := apiclient.ImageInspectWithRaw(ctx, imgName) assert.NilError(t, err) expected := "/foo/sub2" @@ -234,7 +235,7 @@ func TestBuildMultiStageParentConfig(t *testing.T) { func TestBuildLabelWithTargets(t *testing.T) { skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), "test added after 1.38") skip.If(t, testEnv.DaemonInfo.OSType == "windows", "FIXME") - bldName := "build-a" + imgName := strings.ToLower(t.Name() + "-a") testLabels := map[string]string{ "foo": "bar", "dead": "beef", @@ -260,7 +261,7 @@ func TestBuildLabelWithTargets(t *testing.T) { types.ImageBuildOptions{ Remove: true, ForceRemove: true, - Tags: []string{bldName}, + Tags: []string{imgName}, Labels: testLabels, Target: "target-a", }) @@ -269,7 +270,7 @@ func TestBuildLabelWithTargets(t *testing.T) { resp.Body.Close() assert.NilError(t, err) - image, _, err := apiclient.ImageInspectWithRaw(ctx, bldName) + image, _, err := apiclient.ImageInspectWithRaw(ctx, imgName) assert.NilError(t, err) testLabels["label-a"] = "inline-a" @@ -280,14 +281,14 @@ func TestBuildLabelWithTargets(t *testing.T) { } // For `target-b` build - bldName = "build-b" + imgName = strings.ToLower(t.Name() + "-b") delete(testLabels, "label-a") resp, err = apiclient.ImageBuild(ctx, source.AsTarReader(t), types.ImageBuildOptions{ Remove: true, ForceRemove: true, - Tags: []string{bldName}, + Tags: []string{imgName}, Labels: testLabels, Target: "target-b", }) @@ -296,7 +297,7 @@ func TestBuildLabelWithTargets(t *testing.T) { resp.Body.Close() assert.NilError(t, err) - image, _, err = apiclient.ImageInspectWithRaw(ctx, bldName) + image, _, err = apiclient.ImageInspectWithRaw(ctx, imgName) assert.NilError(t, err) testLabels["label-b"] = "inline-b" @@ -581,7 +582,7 @@ func TestBuildPreserveOwnership(t *testing.T) { ctx := context.Background() - dockerfile, err := ioutil.ReadFile("testdata/Dockerfile.testBuildPreserveOwnership") + dockerfile, err := ioutil.ReadFile("testdata/Dockerfile." + t.Name()) assert.NilError(t, err) source := fakecontext.New(t, "", fakecontext.WithDockerfile(string(dockerfile))) diff --git a/integration/build/testdata/Dockerfile.testBuildPreserveOwnership b/integration/build/testdata/Dockerfile.TestBuildPreserveOwnership similarity index 100% rename from integration/build/testdata/Dockerfile.testBuildPreserveOwnership rename to integration/build/testdata/Dockerfile.TestBuildPreserveOwnership