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 |
-ADD 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' ]
|
| ... | ... |
@@ -62,31 +62,26 @@ func TestBuildSixtySteps(t *testing.T) {
|
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
func TestBuildAddSingleFileToRoot(t *testing.T) {
|
| 65 |
- testDirName := "SingleFileToRoot" |
|
| 66 |
- sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd", testDirName) |
|
| 67 |
- buildDirectory, err := ioutil.TempDir("", "test-build-add")
|
|
| 68 |
- defer os.RemoveAll(buildDirectory) |
|
| 69 |
- |
|
| 70 |
- err = copyWithCP(sourceDirectory, buildDirectory) |
|
| 71 |
- if err != nil {
|
|
| 72 |
- t.Fatalf("failed to copy files to temporary directory: %s", err)
|
|
| 73 |
- } |
|
| 74 |
- |
|
| 75 |
- buildDirectory = filepath.Join(buildDirectory, testDirName) |
|
| 76 |
- f, err := os.OpenFile(filepath.Join(buildDirectory, "test_file"), os.O_CREATE, 0644) |
|
| 65 |
+ name := "testaddimg" |
|
| 66 |
+ defer deleteImages(name) |
|
| 67 |
+ ctx, err := fakeContext(`FROM busybox |
|
| 68 |
+RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd |
|
| 69 |
+RUN echo 'dockerio:x:1001:' >> /etc/group |
|
| 70 |
+RUN touch /exists |
|
| 71 |
+RUN chown dockerio.dockerio /exists |
|
| 72 |
+ADD test_file / |
|
| 73 |
+RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
| 74 |
+RUN [ $(ls -l /test_file | awk '{print $1}') = '-rw-r--r--' ]
|
|
| 75 |
+RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
|
| 76 |
+ map[string]string{
|
|
| 77 |
+ "test_file": "test1", |
|
| 78 |
+ }) |
|
| 77 | 79 |
if err != nil {
|
| 78 | 80 |
t.Fatal(err) |
| 79 | 81 |
} |
| 80 |
- f.Close() |
|
| 81 |
- out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", ".") |
|
| 82 |
- errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
| 83 |
- |
|
| 84 |
- if err != nil || exitCode != 0 {
|
|
| 85 |
- t.Fatal("failed to build the image")
|
|
| 82 |
+ if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
|
| 83 |
+ t.Fatal(err) |
|
| 86 | 84 |
} |
| 87 |
- |
|
| 88 |
- deleteImages("testaddimg")
|
|
| 89 |
- |
|
| 90 | 85 |
logDone("build - add single file to root")
|
| 91 | 86 |
} |
| 92 | 87 |
|