From 52cf331206b9e50ba9b52f950b5a377179cf7aa5 Mon Sep 17 00:00:00 2001 From: Alexandr Morozov Date: Wed, 24 Sep 2014 13:15:55 +0400 Subject: [PATCH] Rewrite TestBuildRm to not use fixtures Signed-off-by: Alexandr Morozov --- .../build_tests/TestBuildRm/Dockerfile | 4 --- integration-cli/build_tests/TestBuildRm/foo | 1 - integration-cli/docker_cli_build_test.go | 28 +++++++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) delete mode 100644 integration-cli/build_tests/TestBuildRm/Dockerfile delete mode 100644 integration-cli/build_tests/TestBuildRm/foo diff --git a/integration-cli/build_tests/TestBuildRm/Dockerfile b/integration-cli/build_tests/TestBuildRm/Dockerfile deleted file mode 100644 index 190eacf117..0000000000 --- a/integration-cli/build_tests/TestBuildRm/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM busybox -ADD foo / -ADD foo / - diff --git a/integration-cli/build_tests/TestBuildRm/foo b/integration-cli/build_tests/TestBuildRm/foo deleted file mode 100644 index 5716ca5987..0000000000 --- a/integration-cli/build_tests/TestBuildRm/foo +++ /dev/null @@ -1 +0,0 @@ -bar diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 0eecb58dfe..817990cc50 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -633,17 +633,23 @@ func TestBuildForceRm(t *testing.T) { } func TestBuildRm(t *testing.T) { + name := "testbuildrm" + defer deleteImages(name) + ctx, err := fakeContext("FROM scratch\nADD foo /\nADD foo /", map[string]string{"foo": "bar"}) + if err != nil { + t.Fatal(err) + } + defer ctx.Close() { containerCountBefore, err := getContainerCount() if err != nil { t.Fatalf("failed to get the container count: %s", err) } - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildRm") - _, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "--rm", "-t", "testbuildrm", ".") + out, exitCode, err := dockerCmdInDir(t, ctx.Dir, "build", "--rm", "-t", name, ".") if err != nil || exitCode != 0 { - t.Fatal("failed to build the image") + t.Fatal("failed to build the image", out) } containerCountAfter, err := getContainerCount() @@ -654,7 +660,7 @@ func TestBuildRm(t *testing.T) { if containerCountBefore != containerCountAfter { t.Fatalf("-rm shouldn't have left containers behind") } - deleteImages("testbuildrm") + deleteImages(name) } { @@ -663,11 +669,10 @@ func TestBuildRm(t *testing.T) { t.Fatalf("failed to get the container count: %s", err) } - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildRm") - _, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testbuildrm", ".") + out, exitCode, err := dockerCmdInDir(t, ctx.Dir, "build", "-t", name, ".") if err != nil || exitCode != 0 { - t.Fatal("failed to build the image") + t.Fatal("failed to build the image", out) } containerCountAfter, err := getContainerCount() @@ -678,7 +683,7 @@ func TestBuildRm(t *testing.T) { if containerCountBefore != containerCountAfter { t.Fatalf("--rm shouldn't have left containers behind") } - deleteImages("testbuildrm") + deleteImages(name) } { @@ -687,11 +692,10 @@ func TestBuildRm(t *testing.T) { t.Fatalf("failed to get the container count: %s", err) } - buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildRm") - _, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "--rm=false", "-t", "testbuildrm", ".") + out, exitCode, err := dockerCmdInDir(t, ctx.Dir, "build", "--rm=false", "-t", name, ".") if err != nil || exitCode != 0 { - t.Fatal("failed to build the image") + t.Fatal("failed to build the image", out) } containerCountAfter, err := getContainerCount() @@ -703,7 +707,7 @@ func TestBuildRm(t *testing.T) { t.Fatalf("--rm=false should have left containers behind") } deleteAllContainers() - deleteImages("testbuildrm") + deleteImages(name) }