Browse code

Rewrite TestBuildAddDirContentToExistDir to not use fixtures

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

Alexandr Morozov authored on 2014/09/23 02:21:39
Showing 3 changed files
1 1
deleted file mode 100644
... ...
@@ -1,10 +0,0 @@
1
-FROM busybox
2
-RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
3
-RUN echo 'dockerio:x:1001:' >> /etc/group
4
-RUN mkdir /exists
5
-RUN touch /exists/exists_file
6
-RUN chown -R dockerio.dockerio /exists
7
-ADD test_dir/ /exists/
8
-RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
9
-RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
10
-RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]
11 1
deleted file mode 100644
... ...
@@ -244,16 +244,27 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
244 244
 }
245 245
 
246 246
 func TestBuildAddDirContentToExistDir(t *testing.T) {
247
-	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
248
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", "DirContentToExistDir")
249
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
250
-
251
-	if err != nil || exitCode != 0 {
252
-		t.Fatal("failed to build the image")
247
+	name := "testadddircontenttoexistdir"
248
+	defer deleteImages(name)
249
+	ctx, err := fakeContext(`FROM busybox
250
+RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
251
+RUN echo 'dockerio:x:1001:' >> /etc/group
252
+RUN mkdir /exists
253
+RUN touch /exists/exists_file
254
+RUN chown -R dockerio.dockerio /exists
255
+ADD test_dir/ /exists/
256
+RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
257
+RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
258
+RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`,
259
+		map[string]string{
260
+			"test_dir/test_file": "test1",
261
+		})
262
+	if err != nil {
263
+		t.Fatal(err)
264
+	}
265
+	if _, err := buildImageFromContext(name, ctx, true); err != nil {
266
+		t.Fatal(err)
253 267
 	}
254
-
255
-	deleteImages("testaddimg")
256
-
257 268
 	logDone("build - add directory contents to existing dir")
258 269
 }
259 270