mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integ-cli: add test for links in volumes
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
parent
7496cbbccc
commit
a57eee2229
1 changed files with 52 additions and 0 deletions
|
@ -1385,6 +1385,58 @@ func TestBuildAddBadLinks(t *testing.T) {
|
|||
logDone("build - ADD must add files in container")
|
||||
}
|
||||
|
||||
func TestBuildAddBadLinksVolume(t *testing.T) {
|
||||
const (
|
||||
dockerfileTemplate = `
|
||||
FROM busybox
|
||||
RUN ln -s /../../../../../../../../%s /x
|
||||
VOLUME /x
|
||||
ADD foo.txt /x/`
|
||||
targetFile = "foo.txt"
|
||||
)
|
||||
var (
|
||||
name = "test-link-absolute-volume"
|
||||
dockerfile = ""
|
||||
)
|
||||
defer deleteImages(name)
|
||||
|
||||
tempDir, err := ioutil.TempDir("", "test-link-absolute-volume-temp-")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temporary directory: %s", tempDir)
|
||||
}
|
||||
defer os.RemoveAll(tempDir)
|
||||
|
||||
dockerfile = fmt.Sprintf(dockerfileTemplate, tempDir)
|
||||
nonExistingFile := filepath.Join(tempDir, targetFile)
|
||||
|
||||
ctx, err := fakeContext(dockerfile, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer ctx.Close()
|
||||
fooPath := filepath.Join(ctx.Dir, targetFile)
|
||||
|
||||
foo, err := os.Create(fooPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer foo.Close()
|
||||
|
||||
if _, err := foo.WriteString("test"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(nonExistingFile); err == nil || err != nil && !os.IsNotExist(err) {
|
||||
t.Fatalf("%s shouldn't have been written and it shouldn't exist", nonExistingFile)
|
||||
}
|
||||
|
||||
logDone("build - ADD should add files in volume")
|
||||
}
|
||||
|
||||
// Issue #5270 - ensure we throw a better error than "unexpected EOF"
|
||||
// when we can't access files in the context.
|
||||
func TestBuildWithInaccessibleFilesInContext(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue