Browse code

add test

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)

Victor Vieux authored on 2014/05/21 06:29:19
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+FROM busybox
1
+ADD https://index.docker.io/robots.txt /
0 2
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+FROM busybox
1
+ADD http://example.com/index.html /
... ...
@@ -9,6 +9,37 @@ import (
9 9
 	"testing"
10 10
 )
11 11
 
12
+func TestBuildCacheADD(t *testing.T) {
13
+	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildCacheADD", "1")
14
+	buildCmd := exec.Command(dockerBinary, "build", "-t", "testcacheadd1", ".")
15
+	buildCmd.Dir = buildDirectory
16
+	exitCode, err := runCommand(buildCmd)
17
+	errorOut(err, t, fmt.Sprintf("build failed to complete: %v", err))
18
+
19
+	if err != nil || exitCode != 0 {
20
+		t.Fatal("failed to build the image")
21
+	}
22
+
23
+	buildDirectory = filepath.Join(workingDirectory, "build_tests", "TestBuildCacheADD", "2")
24
+	buildCmd = exec.Command(dockerBinary, "build", "-t", "testcacheadd2", ".")
25
+	buildCmd.Dir = buildDirectory
26
+	out, exitCode, err := runCommandWithOutput(buildCmd)
27
+	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
28
+
29
+	if err != nil || exitCode != 0 {
30
+		t.Fatal("failed to build the image")
31
+	}
32
+
33
+	if strings.Contains(out, "Using cache") {
34
+		t.Fatal("2nd build used cache on ADD, it shouldn't")
35
+	}
36
+
37
+	deleteImages("testcacheadd1")
38
+	deleteImages("testcacheadd2")
39
+
40
+	logDone("build - build two images with ADD")
41
+}
42
+
12 43
 func TestBuildSixtySteps(t *testing.T) {
13 44
 	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildSixtySteps")
14 45
 	buildCmd := exec.Command(dockerBinary, "build", "-t", "foobuildsixtysteps", ".")