Skip to content

Commit

Permalink
Merge pull request #688 from tonistiigi/test-empty-dest
Browse files Browse the repository at this point in the history
dockerfile: add test for empty copy directory
  • Loading branch information
tonistiigi authored Oct 16, 2018
2 parents c8f1541 + 94a6c5c commit abdbc66
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions frontend/dockerfile/dockerfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,40 @@ func TestIntegration(t *testing.T) {
testCopyThroughSymlinkContext,
testCopyThroughSymlinkMultiStage,
testCopyChownCreateDest,
testEmptyDestDir,
}, opts...)
}

func testEmptyDestDir(t *testing.T, sb integration.Sandbox) {
f := getFrontend(t, sb)

dockerfile := []byte(`
FROM busybox
ENV empty=""
COPY testfile $empty
RUN [ "$(cat testfile)" == "contents0" ]
`)

dir, err := tmpdir(
fstest.CreateFile("Dockerfile", dockerfile, 0600),
fstest.CreateFile("testfile", []byte("contents0"), 0600),
)
require.NoError(t, err)
defer os.RemoveAll(dir)

c, err := client.New(context.TODO(), sb.Address())
require.NoError(t, err)
defer c.Close()

_, err = f.Solve(context.TODO(), c, client.SolveOpt{
LocalDirs: map[string]string{
builder.LocalNameDockerfile: dir,
builder.LocalNameContext: dir,
},
}, nil)
require.NoError(t, err)
}

func testCopyChownCreateDest(t *testing.T, sb integration.Sandbox) {
f := getFrontend(t, sb)

Expand Down

0 comments on commit abdbc66

Please sign in to comment.