Browse code

Rewrite TestBuildCopyDirContentToExistDir to not use fixtures

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

Alexandr Morozov authored on 2014/10/15 02:26:20
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
-COPY 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
... ...
@@ -759,13 +759,27 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
759 759
 }
760 760
 
761 761
 func TestBuildCopyDirContentToExistDir(t *testing.T) {
762
-	buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy")
763
-	if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "DirContentToExistDir"); err != nil {
764
-		t.Fatalf("build failed to complete: %s, %v", out, err)
762
+	name := "testcopydircontenttoexistdir"
763
+	defer deleteImages(name)
764
+	ctx, err := fakeContext(`FROM busybox
765
+RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
766
+RUN echo 'dockerio:x:1001:' >> /etc/group
767
+RUN mkdir /exists
768
+RUN touch /exists/exists_file
769
+RUN chown -R dockerio.dockerio /exists
770
+COPY test_dir/ /exists/
771
+RUN [ $(ls -l / | grep exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
772
+RUN [ $(ls -l /exists/exists_file | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
773
+RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`,
774
+		map[string]string{
775
+			"test_dir/test_file": "test1",
776
+		})
777
+	if err != nil {
778
+		t.Fatal(err)
779
+	}
780
+	if _, err := buildImageFromContext(name, ctx, true); err != nil {
781
+		t.Fatal(err)
765 782
 	}
766
-
767
-	deleteImages("testcopyimg")
768
-
769 783
 	logDone("build - copy directory contents to existing dir")
770 784
 }
771 785