Browse code

Rewrite TestBuildHistory to not use fixtures

Signed-off-by: Alexandr Morozov <lk4d4@docker.com>

Alexandr Morozov authored on 2014/09/24 17:38:48
Showing 2 changed files
1 1
deleted file mode 100644
... ...
@@ -1,28 +0,0 @@
1
-FROM busybox
2
-
3
-RUN echo "A"
4
-RUN echo "B"
5
-RUN echo "C"
6
-RUN echo "D"
7
-RUN echo "E"
8
-RUN echo "F"
9
-RUN echo "G"
10
-RUN echo "H"
11
-RUN echo "I"
12
-RUN echo "J"
13
-RUN echo "K"
14
-RUN echo "L"
15
-RUN echo "M"
16
-RUN echo "N"
17
-RUN echo "O"
18
-RUN echo "P"
19
-RUN echo "Q"
20
-RUN echo "R"
21
-RUN echo "S"
22
-RUN echo "T"
23
-RUN echo "U"
24
-RUN echo "V"
25
-RUN echo "W"
26
-RUN echo "X"
27
-RUN echo "Y"
28
-RUN echo "Z"
... ...
@@ -3,7 +3,6 @@ package main
3 3
 import (
4 4
 	"fmt"
5 5
 	"os/exec"
6
-	"path/filepath"
7 6
 	"strings"
8 7
 	"testing"
9 8
 )
... ...
@@ -11,17 +10,42 @@ import (
11 11
 // This is a heisen-test.  Because the created timestamp of images and the behavior of
12 12
 // sort is not predictable it doesn't always fail.
13 13
 func TestBuildHistory(t *testing.T) {
14
-	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildHistory")
15
-	buildCmd := exec.Command(dockerBinary, "build", "-t", "testbuildhistory", ".")
14
+	name := "testbuildhistory"
15
+	defer deleteImages(name)
16
+	_, err := buildImage(name, `FROM busybox
17
+RUN echo "A"
18
+RUN echo "B"
19
+RUN echo "C"
20
+RUN echo "D"
21
+RUN echo "E"
22
+RUN echo "F"
23
+RUN echo "G"
24
+RUN echo "H"
25
+RUN echo "I"
26
+RUN echo "J"
27
+RUN echo "K"
28
+RUN echo "L"
29
+RUN echo "M"
30
+RUN echo "N"
31
+RUN echo "O"
32
+RUN echo "P"
33
+RUN echo "Q"
34
+RUN echo "R"
35
+RUN echo "S"
36
+RUN echo "T"
37
+RUN echo "U"
38
+RUN echo "V"
39
+RUN echo "W"
40
+RUN echo "X"
41
+RUN echo "Y"
42
+RUN echo "Z"`,
43
+		true)
16 44
 
17
-	buildCmd.Dir = buildDirectory
18
-	out, exitCode, err := runCommandWithOutput(buildCmd)
19
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
20
-	if err != nil || exitCode != 0 {
21
-		t.Fatal("failed to build the image")
45
+	if err != nil {
46
+		t.Fatal(err)
22 47
 	}
23 48
 
24
-	out, exitCode, err = runCommandWithOutput(exec.Command(dockerBinary, "history", "testbuildhistory"))
49
+	out, exitCode, err := runCommandWithOutput(exec.Command(dockerBinary, "history", "testbuildhistory"))
25 50
 	errorOut(err, t, fmt.Sprintf("image history failed: %v %v", out, err))
26 51
 	if err != nil || exitCode != 0 {
27 52
 		t.Fatal("failed to get image history")
... ...
@@ -39,8 +63,6 @@ func TestBuildHistory(t *testing.T) {
39 39
 		}
40 40
 	}
41 41
 
42
-	deleteImages("testbuildhistory")
43
-
44 42
 	logDone("history - build history")
45 43
 }
46 44