Rewrite TestBuildCopyWholeDirToRoot to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
4a029259ff
commit
6582ea574c
|
@ -1,11 +0,0 @@
|
||||||
FROM busybox
|
|
||||||
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
|
||||||
RUN echo 'dockerio:x:1001:' >> /etc/group
|
|
||||||
RUN touch /exists
|
|
||||||
RUN chown dockerio.dockerio exists
|
|
||||||
COPY test_dir /test_dir
|
|
||||||
RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ]
|
|
||||||
RUN [ $(ls -l / | grep test_dir | awk '{print $1}') = 'drwxr-xr-x' ]
|
|
||||||
RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
||||||
RUN [ $(ls -l /test_dir/test_file | awk '{print $1}') = '-rw-r--r--' ]
|
|
||||||
RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
|
|
|
@ -784,32 +784,28 @@ RUN [ $(ls -l /exists/test_file | awk '{print $3":"$4}') = 'root:root' ]`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildCopyWholeDirToRoot(t *testing.T) {
|
func TestBuildCopyWholeDirToRoot(t *testing.T) {
|
||||||
testDirName := "WholeDirToRoot"
|
name := "testcopywholedirtoroot"
|
||||||
sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy", testDirName)
|
defer deleteImages(name)
|
||||||
buildDirectory, err := ioutil.TempDir("", "test-build-add")
|
ctx, err := fakeContext(`FROM busybox
|
||||||
defer os.RemoveAll(buildDirectory)
|
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
||||||
|
RUN echo 'dockerio:x:1001:' >> /etc/group
|
||||||
err = copyWithCP(sourceDirectory, buildDirectory)
|
RUN touch /exists
|
||||||
if err != nil {
|
RUN chown dockerio.dockerio exists
|
||||||
t.Fatalf("failed to copy files to temporary directory: %s", err)
|
COPY test_dir /test_dir
|
||||||
}
|
RUN [ $(ls -l / | grep test_dir | awk '{print $3":"$4}') = 'root:root' ]
|
||||||
|
RUN [ $(ls -l / | grep test_dir | awk '{print $1}') = 'drwxr-xr-x' ]
|
||||||
buildDirectory = filepath.Join(buildDirectory, testDirName)
|
RUN [ $(ls -l /test_dir/test_file | awk '{print $3":"$4}') = 'root:root' ]
|
||||||
testDir := filepath.Join(buildDirectory, "test_dir")
|
RUN [ $(ls -l /test_dir/test_file | awk '{print $1}') = '-rw-r--r--' ]
|
||||||
if err := os.MkdirAll(testDir, 0755); err != nil {
|
RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
||||||
t.Fatal(err)
|
map[string]string{
|
||||||
}
|
"test_dir/test_file": "test1",
|
||||||
f, err := os.OpenFile(filepath.Join(testDir, "test_file"), os.O_CREATE, 0644)
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
f.Close()
|
if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
||||||
if out, _, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil {
|
t.Fatal(err)
|
||||||
t.Fatalf("build failed to complete: %s, %v", out, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteImages("testcopyimg")
|
|
||||||
|
|
||||||
logDone("build - copy whole directory to root")
|
logDone("build - copy whole directory to root")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue