mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Rewrite TestAddSingleFileToRoot to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
3824ec62e8
commit
682fbe0134
2 changed files with 16 additions and 30 deletions
|
@ -1,9 +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_file /
|
|
||||||
RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
|
|
||||||
RUN [ $(ls -l /test_file | awk '{print $1}') = '-rw-r--r--' ]
|
|
||||||
RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]
|
|
|
@ -62,31 +62,26 @@ func TestBuildSixtySteps(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildAddSingleFileToRoot(t *testing.T) {
|
func TestBuildAddSingleFileToRoot(t *testing.T) {
|
||||||
testDirName := "SingleFileToRoot"
|
name := "testaddimg"
|
||||||
sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestAdd", 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)
|
ADD test_file /
|
||||||
}
|
RUN [ $(ls -l /test_file | awk '{print $3":"$4}') = 'root:root' ]
|
||||||
|
RUN [ $(ls -l /test_file | awk '{print $1}') = '-rw-r--r--' ]
|
||||||
buildDirectory = filepath.Join(buildDirectory, testDirName)
|
RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
||||||
f, err := os.OpenFile(filepath.Join(buildDirectory, "test_file"), os.O_CREATE, 0644)
|
map[string]string{
|
||||||
|
"test_file": "test1",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
f.Close()
|
if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
||||||
out, exitCode, err := dockerCmdInDir(t, buildDirectory, "build", "-t", "testaddimg", ".")
|
t.Fatal(err)
|
||||||
errorOut(err, t, fmt.Sprintf("build failed to complete: %v %v", out, err))
|
|
||||||
|
|
||||||
if err != nil || exitCode != 0 {
|
|
||||||
t.Fatal("failed to build the image")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteImages("testaddimg")
|
|
||||||
|
|
||||||
logDone("build - add single file to root")
|
logDone("build - add single file to root")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue