1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Add test to enforce volume build content

This tests ensures that the content from a dir within a build is carried
over even if VOLUME for that dir is specified in the Dockerfile.  This
test ensures this long standing functionality.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2014-12-12 11:15:31 -08:00
parent d7d981bf3a
commit 4856ec0754

View file

@ -3914,3 +3914,37 @@ RUN [ ! -e /injected ]`,
logDone("build - xz host is being used")
}
func TestBuildVolumesRetainContents(t *testing.T) {
var (
name = "testbuildvolumescontent"
expected = "some text"
)
defer deleteImages(name)
ctx, err := fakeContext(`
FROM busybox
COPY content /foo/file
VOLUME /foo
CMD cat /foo/file`,
map[string]string{
"content": expected,
})
if err != nil {
t.Fatal(err)
}
defer ctx.Close()
if _, err := buildImageFromContext(name, ctx, false); err != nil {
t.Fatal(err)
}
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "run", "--rm", name))
if err != nil {
t.Fatal(err)
}
if out != expected {
t.Fatalf("expected file contents for /foo/file to be %q but received %q", expected, out)
}
logDone("build - volumes retain contents in build")
}