mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Rewrite TestBuildAddDirContentToRoot to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
139b6ed3aa
commit
2d802d7f23
3 changed files with 18 additions and 17 deletions
|
@ -1,8 +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
|
|
||||||
ADD test_dir /
|
|
||||||
RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
||||||
RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
|
|
|
@ -221,16 +221,25 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildAddDirContentToRoot(t *testing.T) {
|
func TestBuildAddDirContentToRoot(t *testing.T) {
|
||||||
buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd")
|
name := "testadddircontenttoroot"
|
||||||
out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", "DirContentToRoot")
|
defer deleteImages(name)
|
||||||
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
ctx, err := fakeContext(`FROM busybox
|
||||||
|
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
||||||
if err != nil || exitCode != 0 {
|
RUN echo 'dockerio:x:1001:' >> /etc/group
|
||||||
t.Fatal("failed to build the image")
|
RUN touch /exists
|
||||||
|
RUN chown dockerio.dockerio exists
|
||||||
|
ADD test_dir /
|
||||||
|
RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
|
||||||
|
RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
||||||
|
map[string]string{
|
||||||
|
"test_dir/test_file": "test1",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteImages("testaddimg")
|
|
||||||
|
|
||||||
logDone("build - add directory contents to root")
|
logDone("build - add directory contents to root")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue