Browse code

Rewrite TestBuildCopyDirContentToRoot to not use fixtures

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

Alexandr Morozov authored on 2014/10/15 02:22:06
Showing 3 changed files
1 1
deleted file mode 100644
... ...
@@ -1,8 +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 touch /exists
5
-RUN chown dockerio.dockerio exists
6
-COPY test_dir /
7
-RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
8
-RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
9 1
deleted file mode 100644
... ...
@@ -736,13 +736,25 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
736 736
 }
737 737
 
738 738
 func TestBuildCopyDirContentToRoot(t *testing.T) {
739
-	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
740
-	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToRoot"); err != nil {
741
-		t.Fatalf("build failed to complete: %s, %v", out, err)
739
+	name := "testcopydircontenttoroot"
740
+	defer deleteImages(name)
741
+	ctx, err := fakeContext(`FROM busybox
742
+RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
743
+RUN echo 'dockerio:x:1001:' >> /etc/group
744
+RUN touch /exists
745
+RUN chown dockerio.dockerio exists
746
+COPY test_dir /
747
+RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
748
+RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
749
+		map[string]string{
750
+			"test_dir/test_file": "test1",
751
+		})
752
+	if err != nil {
753
+		t.Fatal(err)
754
+	}
755
+	if _, err := buildImageFromContext(name, ctx, true); err != nil {
756
+		t.Fatal(err)
742 757
 	}
743
-
744
-	deleteImages("testcopyimg")
745
-
746 758
 	logDone("build - copy directory contents to root")
747 759
 }
748 760