Browse code

Rewrite TestBuildAddEtcToRoot to not use fixtures

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

Alexandr Morozov authored on 2014/09/23 02:26:51
Showing 2 changed files
1 1
deleted file mode 100644
... ...
@@ -1,2 +0,0 @@
1
-FROM scratch
2
-ADD . /
... ...
@@ -301,16 +301,21 @@ func TestBuildAddWholeDirToRoot(t *testing.T) {
301 301
 	logDone("build - add whole directory to root")
302 302
 }
303 303
 
304
+// Testing #5941
304 305
 func TestBuildAddEtcToRoot(t *testing.T) {
305
-	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
306
-	out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", "EtcToRoot")
307
-	errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
308
-
309
-	if err != nil || exitCode != 0 {
310
-		t.Fatal("failed to build the image")
306
+	name := "testaddetctoroot"
307
+	defer deleteImages(name)
308
+	ctx, err := fakeContext(`FROM scratch
309
+ADD . /`,
310
+		map[string]string{
311
+			"etc/test_file": "test1",
312
+		})
313
+	if err != nil {
314
+		t.Fatal(err)
315
+	}
316
+	if _, err := buildImageFromContext(name, ctx, true); err != nil {
317
+		t.Fatal(err)
311 318
 	}
312
-
313
-	deleteImages("testaddimg")
314 319
 	logDone("build - add etc directory to root")
315 320
 }
316 321