Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,9 +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_file / |
|
| 7 |
-RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
| 8 |
-RUN [ $(ls -l /test_file | awk '{print $1}') = '-rw-r--r--' ]
|
|
| 9 |
-RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
|
| ... | ... |
@@ -636,28 +636,26 @@ ADD . /`, |
| 636 | 636 |
} |
| 637 | 637 |
|
| 638 | 638 |
func TestBuildCopySingleFileToRoot(t *testing.T) {
|
| 639 |
- testDirName := "SingleFileToRoot" |
|
| 640 |
- sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy", testDirName) |
|
| 641 |
- buildDirectory, err := ioutil.TempDir("", "test-build-add")
|
|
| 642 |
- defer os.RemoveAll(buildDirectory) |
|
| 643 |
- |
|
| 644 |
- err = copyWithCP(sourceDirectory, buildDirectory) |
|
| 645 |
- if err != nil {
|
|
| 646 |
- t.Fatalf("failed to copy files to temporary directory: %s", err)
|
|
| 647 |
- } |
|
| 648 |
- |
|
| 649 |
- buildDirectory = filepath.Join(buildDirectory, testDirName) |
|
| 650 |
- f, err := os.OpenFile(filepath.Join(buildDirectory, "test_file"), os.O_CREATE, 0644) |
|
| 639 |
+ name := "testcopysinglefiletoroot" |
|
| 640 |
+ defer deleteImages(name) |
|
| 641 |
+ ctx, err := fakeContext(`FROM busybox |
|
| 642 |
+RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
|
| 643 |
+RUN echo 'dockerio:x:1001:' >> /etc/group |
|
| 644 |
+RUN touch /exists |
|
| 645 |
+RUN chown dockerio.dockerio /exists |
|
| 646 |
+COPY test_file / |
|
| 647 |
+RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
| 648 |
+RUN [ $(ls -l /test_file | awk '{print $1}') = '-rw-r--r--' ]
|
|
| 649 |
+RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
|
| 650 |
+ map[string]string{
|
|
| 651 |
+ "test_file": "test1", |
|
| 652 |
+ }) |
|
| 651 | 653 |
if err != nil {
|
| 652 | 654 |
t.Fatal(err) |
| 653 | 655 |
} |
| 654 |
- f.Close() |
|
| 655 |
- if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil {
|
|
| 656 |
- t.Fatalf("build failed to complete: %s, %v", out, err)
|
|
| 656 |
+ if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
|
| 657 |
+ t.Fatal(err) |
|
| 657 | 658 |
} |
| 658 |
- |
|
| 659 |
- deleteImages("testcopyimg")
|
|
| 660 |
- |
|
| 661 | 659 |
logDone("build - copy single file to root")
|
| 662 | 660 |
} |
| 663 | 661 |
|