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

Move FakeContext to integration-cli/cli/build/context package…

… and continue emptying `docker_utils_test.go` from build related function.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2017-04-10 14:42:21 +02:00
parent a258ef58d8
commit 56fb4653e8
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3
13 changed files with 1011 additions and 935 deletions

View file

@ -16,6 +16,8 @@ import (
"github.com/docker/docker/integration-cli/checker"
"github.com/docker/docker/integration-cli/cli"
"github.com/docker/docker/integration-cli/cli/build"
"github.com/docker/docker/integration-cli/cli/build/fakecontext"
"github.com/docker/docker/pkg/testutil"
icmd "github.com/docker/docker/pkg/testutil/cmd"
"github.com/docker/go-units"
@ -26,10 +28,10 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
testRequires(c, cpuCfsQuota)
name := "testbuildresourceconstraints"
ctx := fakeContext(c, `
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`
FROM hello-world:frozen
RUN ["/hello"]
`, map[string]string{})
`))
cli.Docker(
cli.Args("build", "--no-cache", "--rm=false", "--memory=64m", "--memory-swap=-1", "--cpuset-cpus=0", "--cpuset-mems=0", "--cpu-shares=100", "--cpu-quota=8000", "--ulimit", "nofile=42", "-t", name, "."),
cli.InDir(ctx.Dir),
@ -85,7 +87,7 @@ func (s *DockerSuite) TestBuildAddChangeOwnership(c *check.C) {
testRequires(c, DaemonIsLinux)
name := "testbuildaddown"
ctx := func() *FakeContext {
ctx := func() *fakecontext.Fake {
dockerfile := `
FROM busybox
ADD foo /bar/
@ -108,12 +110,12 @@ func (s *DockerSuite) TestBuildAddChangeOwnership(c *check.C) {
if err := ioutil.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
c.Fatalf("failed to open destination dockerfile: %v", err)
}
return fakeContextFromDir(tmpDir)
return fakecontext.New(c, tmpDir)
}()
defer ctx.Close()
buildImageSuccessfully(c, name, withExternalBuildContext(ctx))
buildImageSuccessfully(c, name, build.WithExternalBuildContext(ctx))
}
// Test that an infinite sleep during a build is killed if the client disconnects.
@ -134,7 +136,7 @@ func (s *DockerSuite) TestBuildCancellationKillsSleep(c *check.C) {
defer observer.Stop()
// (Note: one year, will never finish)
ctx := fakeContext(c, "FROM busybox\nRUN sleep 31536000", nil)
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile("FROM busybox\nRUN sleep 31536000"))
defer ctx.Close()
buildCmd := exec.Command(dockerBinary, "build", "-t", name, ".")