dockerfile: add example mount test
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>docker-18.09
parent
1be3e43527
commit
74754d6a6a
|
@ -0,0 +1,51 @@
|
|||
// +build dfrunmount
|
||||
|
||||
package dockerfile
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/continuity/fs/fstest"
|
||||
"github.com/moby/buildkit/client"
|
||||
"github.com/moby/buildkit/frontend/dockerfile/builder"
|
||||
"github.com/moby/buildkit/util/testutil/integration"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var mountTests = []integration.Test{
|
||||
testMountContext,
|
||||
}
|
||||
|
||||
func init() {
|
||||
allTests = append(allTests, mountTests...)
|
||||
}
|
||||
|
||||
func testMountContext(t *testing.T, sb integration.Sandbox) {
|
||||
f := getFrontend(t, sb)
|
||||
|
||||
dockerfile := []byte(`
|
||||
FROM busybox
|
||||
RUN --mount=target=/context [ "$(cat /context/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)
|
||||
}
|
|
@ -37,6 +37,51 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var allTests = []integration.Test{
|
||||
testNoSnapshotLeak,
|
||||
testCmdShell,
|
||||
testGlobalArg,
|
||||
testDockerfileDirs,
|
||||
testDockerfileInvalidCommand,
|
||||
testDockerfileADDFromURL,
|
||||
testDockerfileAddArchive,
|
||||
testDockerfileScratchConfig,
|
||||
testExportedHistory,
|
||||
testExposeExpansion,
|
||||
testUser,
|
||||
testDockerignore,
|
||||
testDockerignoreInvalid,
|
||||
testDockerfileFromGit,
|
||||
testCopyChown,
|
||||
testCopyWildcards,
|
||||
testCopyOverrideFiles,
|
||||
testMultiStageImplicitFrom,
|
||||
testCopyVarSubstitution,
|
||||
testMultiStageCaseInsensitive,
|
||||
testLabels,
|
||||
testCacheImportExport,
|
||||
testReproducibleIDs,
|
||||
testImportExportReproducibleIDs,
|
||||
testNoCache,
|
||||
testDockerfileFromHTTP,
|
||||
testBuiltinArgs,
|
||||
testPullScratch,
|
||||
testSymlinkDestination,
|
||||
testHTTPDockerfile,
|
||||
testNoSnapshotLeak,
|
||||
testCopySymlinks,
|
||||
testContextChangeDirToFile,
|
||||
testPlatformArgsImplicit,
|
||||
testPlatformArgsExplicit,
|
||||
testExportMultiPlatform,
|
||||
testQuotedMetaArgs,
|
||||
testIgnoreEntrypoint,
|
||||
testCopyThroughSymlinkContext,
|
||||
testCopyThroughSymlinkMultiStage,
|
||||
testCopyChownCreateDest,
|
||||
testEmptyDestDir,
|
||||
}
|
||||
|
||||
var opts []integration.TestOpt
|
||||
|
||||
type frontend interface {
|
||||
|
@ -73,50 +118,7 @@ func init() {
|
|||
}
|
||||
|
||||
func TestIntegration(t *testing.T) {
|
||||
integration.Run(t, []integration.Test{
|
||||
testNoSnapshotLeak,
|
||||
testCmdShell,
|
||||
testGlobalArg,
|
||||
testDockerfileDirs,
|
||||
testDockerfileInvalidCommand,
|
||||
testDockerfileADDFromURL,
|
||||
testDockerfileAddArchive,
|
||||
testDockerfileScratchConfig,
|
||||
testExportedHistory,
|
||||
testExposeExpansion,
|
||||
testUser,
|
||||
testDockerignore,
|
||||
testDockerignoreInvalid,
|
||||
testDockerfileFromGit,
|
||||
testCopyChown,
|
||||
testCopyWildcards,
|
||||
testCopyOverrideFiles,
|
||||
testMultiStageImplicitFrom,
|
||||
testCopyVarSubstitution,
|
||||
testMultiStageCaseInsensitive,
|
||||
testLabels,
|
||||
testCacheImportExport,
|
||||
testReproducibleIDs,
|
||||
testImportExportReproducibleIDs,
|
||||
testNoCache,
|
||||
testDockerfileFromHTTP,
|
||||
testBuiltinArgs,
|
||||
testPullScratch,
|
||||
testSymlinkDestination,
|
||||
testHTTPDockerfile,
|
||||
testNoSnapshotLeak,
|
||||
testCopySymlinks,
|
||||
testContextChangeDirToFile,
|
||||
testPlatformArgsImplicit,
|
||||
testPlatformArgsExplicit,
|
||||
testExportMultiPlatform,
|
||||
testQuotedMetaArgs,
|
||||
testIgnoreEntrypoint,
|
||||
testCopyThroughSymlinkContext,
|
||||
testCopyThroughSymlinkMultiStage,
|
||||
testCopyChownCreateDest,
|
||||
testEmptyDestDir,
|
||||
}, opts...)
|
||||
integration.Run(t, allTests, opts...)
|
||||
}
|
||||
|
||||
func testEmptyDestDir(t *testing.T, sb integration.Sandbox) {
|
||||
|
|
Loading…
Reference in New Issue