Browse code

Clean some docker_cli_build_tests that are cli-only

Remove TestBuildRenamedDockerfile and TestBuildDockerfileOutsideContext
that are cli-only tests (and already tested in the docker/cli
repository).

Also adds some comments on few tests that could be migrate to
docker/cli.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2018/02/27 21:42:29
Showing 1 changed files
... ...
@@ -1439,6 +1439,7 @@ func (s *DockerSuite) TestBuildRelativeCopy(c *check.C) {
1439 1439
 	))
1440 1440
 }
1441 1441
 
1442
+// FIXME(vdemeester) should be unit test
1442 1443
 func (s *DockerSuite) TestBuildBlankName(c *check.C) {
1443 1444
 	name := "testbuildblankname"
1444 1445
 	testCases := []struct {
... ...
@@ -2066,6 +2067,7 @@ func (s *DockerSuite) TestBuildNoContext(c *check.C) {
2066 2066
 	}
2067 2067
 }
2068 2068
 
2069
+// FIXME(vdemeester) migrate to docker/cli e2e
2069 2070
 func (s *DockerSuite) TestBuildDockerfileStdin(c *check.C) {
2070 2071
 	name := "stdindockerfile"
2071 2072
 	tmpDir, err := ioutil.TempDir("", "fake-context")
... ...
@@ -2085,6 +2087,7 @@ CMD ["cat", "/foo"]`),
2085 2085
 	c.Assert(strings.TrimSpace(string(res)), checker.Equals, `[cat /foo]`)
2086 2086
 }
2087 2087
 
2088
+// FIXME(vdemeester) migrate to docker/cli tests (unit or e2e)
2088 2089
 func (s *DockerSuite) TestBuildDockerfileStdinConflict(c *check.C) {
2089 2090
 	name := "stdindockerfiletarcontext"
2090 2091
 	icmd.RunCmd(icmd.Cmd{
... ...
@@ -2401,6 +2404,7 @@ func (s *DockerSuite) TestBuildDockerignoringDockerfile(c *check.C) {
2401 2401
 		build.WithFile("Dockerfile", dockerfile),
2402 2402
 		build.WithFile(".dockerignore", "Dockerfile\n"),
2403 2403
 	))
2404
+	// FIXME(vdemeester) why twice ?
2404 2405
 	buildImageSuccessfully(c, name, build.WithBuildContext(c,
2405 2406
 		build.WithFile("Dockerfile", dockerfile),
2406 2407
 		build.WithFile(".dockerignore", "./Dockerfile\n"),
... ...
@@ -2420,6 +2424,7 @@ func (s *DockerSuite) TestBuildDockerignoringRenamedDockerfile(c *check.C) {
2420 2420
 		build.WithFile("MyDockerfile", dockerfile),
2421 2421
 		build.WithFile(".dockerignore", "MyDockerfile\n"),
2422 2422
 	))
2423
+	// FIXME(vdemeester) why twice ?
2423 2424
 	buildImageSuccessfully(c, name, cli.WithFlags("-f", "MyDockerfile"), build.WithBuildContext(c,
2424 2425
 		build.WithFile("Dockerfile", "Should not use me"),
2425 2426
 		build.WithFile("MyDockerfile", dockerfile),
... ...
@@ -3045,6 +3050,7 @@ func (s *DockerSuite) TestBuildAddTarXzGz(c *check.C) {
3045 3045
 	buildImageSuccessfully(c, name, build.WithExternalBuildContext(ctx))
3046 3046
 }
3047 3047
 
3048
+// FIXME(vdemeester) most of the from git tests could be moved to `docker/cli` e2e tests
3048 3049
 func (s *DockerSuite) TestBuildFromGit(c *check.C) {
3049 3050
 	name := "testbuildfromgit"
3050 3051
 	git := fakegit.New(c, "repo", map[string]string{
... ...
@@ -3422,6 +3428,7 @@ func (s *DockerSuite) TestBuildLabelsCache(c *check.C) {
3422 3422
 
3423 3423
 }
3424 3424
 
3425
+// FIXME(vdemeester) port to docker/cli e2e tests (api tests should test suppressOutput option though)
3425 3426
 func (s *DockerSuite) TestBuildNotVerboseSuccess(c *check.C) {
3426 3427
 	// This test makes sure that -q works correctly when build is successful:
3427 3428
 	// stdout has only the image ID (long image ID) and stderr is empty.
... ...
@@ -3472,6 +3479,7 @@ func (s *DockerSuite) TestBuildNotVerboseSuccess(c *check.C) {
3472 3472
 
3473 3473
 }
3474 3474
 
3475
+// FIXME(vdemeester) migrate to docker/cli tests
3475 3476
 func (s *DockerSuite) TestBuildNotVerboseFailureWithNonExistImage(c *check.C) {
3476 3477
 	// This test makes sure that -q works correctly when build fails by
3477 3478
 	// comparing between the stderr output in quiet mode and in stdout
... ...
@@ -3492,6 +3500,7 @@ func (s *DockerSuite) TestBuildNotVerboseFailureWithNonExistImage(c *check.C) {
3492 3492
 	}
3493 3493
 }
3494 3494
 
3495
+// FIXME(vdemeester) migrate to docker/cli tests
3495 3496
 func (s *DockerSuite) TestBuildNotVerboseFailure(c *check.C) {
3496 3497
 	// This test makes sure that -q works correctly when build fails by
3497 3498
 	// comparing between the stderr output in quiet mode and in stdout
... ...
@@ -3519,6 +3528,7 @@ func (s *DockerSuite) TestBuildNotVerboseFailure(c *check.C) {
3519 3519
 	}
3520 3520
 }
3521 3521
 
3522
+// FIXME(vdemeester) migrate to docker/cli tests
3522 3523
 func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *check.C) {
3523 3524
 	// This test ensures that when given a wrong URL, stderr in quiet mode and
3524 3525
 	// stderr in verbose mode are identical.
... ...
@@ -3548,6 +3558,7 @@ func (s *DockerSuite) TestBuildNotVerboseFailureRemote(c *check.C) {
3548 3548
 	}
3549 3549
 }
3550 3550
 
3551
+// FIXME(vdemeester) migrate to docker/cli tests
3551 3552
 func (s *DockerSuite) TestBuildStderr(c *check.C) {
3552 3553
 	// This test just makes sure that no non-error output goes
3553 3554
 	// to stderr
... ...
@@ -3688,67 +3699,6 @@ CMD cat /foo/file`),
3688 3688
 
3689 3689
 }
3690 3690
 
3691
-// FIXME(vdemeester) part of this should be unit test, other part should be clearer
3692
-func (s *DockerSuite) TestBuildRenamedDockerfile(c *check.C) {
3693
-	ctx := fakecontext.New(c, "", fakecontext.WithFiles(map[string]string{
3694
-		"Dockerfile":       "FROM busybox\nRUN echo from Dockerfile",
3695
-		"files/Dockerfile": "FROM busybox\nRUN echo from files/Dockerfile",
3696
-		"files/dFile":      "FROM busybox\nRUN echo from files/dFile",
3697
-		"dFile":            "FROM busybox\nRUN echo from dFile",
3698
-		"files/dFile2":     "FROM busybox\nRUN echo from files/dFile2",
3699
-	}))
3700
-	defer ctx.Close()
3701
-
3702
-	cli.Docker(cli.Args("build", "-t", "test1", "."), cli.InDir(ctx.Dir)).Assert(c, icmd.Expected{
3703
-		Out: "from Dockerfile",
3704
-	})
3705
-
3706
-	cli.Docker(cli.Args("build", "-f", filepath.Join("files", "Dockerfile"), "-t", "test2", "."), cli.InDir(ctx.Dir)).Assert(c, icmd.Expected{
3707
-		Out: "from files/Dockerfile",
3708
-	})
3709
-
3710
-	cli.Docker(cli.Args("build", fmt.Sprintf("--file=%s", filepath.Join("files", "dFile")), "-t", "test3", "."), cli.InDir(ctx.Dir)).Assert(c, icmd.Expected{
3711
-		Out: "from files/dFile",
3712
-	})
3713
-
3714
-	cli.Docker(cli.Args("build", "--file=dFile", "-t", "test4", "."), cli.InDir(ctx.Dir)).Assert(c, icmd.Expected{
3715
-		Out: "from dFile",
3716
-	})
3717
-
3718
-	dirWithNoDockerfile, err := ioutil.TempDir(os.TempDir(), "test5")
3719
-	c.Assert(err, check.IsNil)
3720
-	nonDockerfileFile := filepath.Join(dirWithNoDockerfile, "notDockerfile")
3721
-	if _, err = os.Create(nonDockerfileFile); err != nil {
3722
-		c.Fatal(err)
3723
-	}
3724
-	cli.Docker(cli.Args("build", fmt.Sprintf("--file=%s", nonDockerfileFile), "-t", "test5", "."), cli.InDir(ctx.Dir)).Assert(c, icmd.Expected{
3725
-		ExitCode: 1,
3726
-		Err:      fmt.Sprintf("unable to prepare context: the Dockerfile (%s) must be within the build context", nonDockerfileFile),
3727
-	})
3728
-
3729
-	cli.Docker(cli.Args("build", "-f", filepath.Join("..", "Dockerfile"), "-t", "test6", ".."), cli.InDir(filepath.Join(ctx.Dir, "files"))).Assert(c, icmd.Expected{
3730
-		Out: "from Dockerfile",
3731
-	})
3732
-
3733
-	cli.Docker(cli.Args("build", "-f", filepath.Join(ctx.Dir, "files", "Dockerfile"), "-t", "test7", ".."), cli.InDir(filepath.Join(ctx.Dir, "files"))).Assert(c, icmd.Expected{
3734
-		Out: "from files/Dockerfile",
3735
-	})
3736
-
3737
-	cli.Docker(cli.Args("build", "-f", filepath.Join("..", "Dockerfile"), "-t", "test8", "."), cli.InDir(filepath.Join(ctx.Dir, "files"))).Assert(c, icmd.Expected{
3738
-		ExitCode: 1,
3739
-		Err:      "must be within the build context",
3740
-	})
3741
-
3742
-	tmpDir := os.TempDir()
3743
-	cli.Docker(cli.Args("build", "-t", "test9", ctx.Dir), cli.InDir(tmpDir)).Assert(c, icmd.Expected{
3744
-		Out: "from Dockerfile",
3745
-	})
3746
-
3747
-	cli.Docker(cli.Args("build", "-f", "dFile2", "-t", "test10", "."), cli.InDir(filepath.Join(ctx.Dir, "files"))).Assert(c, icmd.Expected{
3748
-		Out: "from files/dFile2",
3749
-	})
3750
-}
3751
-
3752 3691
 func (s *DockerSuite) TestBuildFromMixedcaseDockerfile(c *check.C) {
3753 3692
 	testRequires(c, UnixCli) // Dockerfile overwrites dockerfile on windows
3754 3693
 	testRequires(c, DaemonIsLinux)
... ...
@@ -3772,6 +3722,7 @@ func (s *DockerSuite) TestBuildFromMixedcaseDockerfile(c *check.C) {
3772 3772
 	})
3773 3773
 }
3774 3774
 
3775
+// FIXME(vdemeester) should migrate to docker/cli tests
3775 3776
 func (s *DockerSuite) TestBuildFromURLWithF(c *check.C) {
3776 3777
 	server := fakestorage.New(c, "", fakecontext.WithFiles(map[string]string{"baz": `FROM busybox
3777 3778
 RUN echo from baz
... ...
@@ -3798,6 +3749,7 @@ RUN find /tmp/`}))
3798 3798
 
3799 3799
 }
3800 3800
 
3801
+// FIXME(vdemeester) should migrate to docker/cli tests
3801 3802
 func (s *DockerSuite) TestBuildFromStdinWithF(c *check.C) {
3802 3803
 	testRequires(c, DaemonIsLinux) // TODO Windows: This test is flaky; no idea why
3803 3804
 	ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(`FROM busybox
... ...
@@ -3840,61 +3792,6 @@ func (s *DockerSuite) TestBuildFromOfficialNames(c *check.C) {
3840 3840
 	}
3841 3841
 }
3842 3842
 
3843
-func (s *DockerSuite) TestBuildDockerfileOutsideContext(c *check.C) {
3844
-	testRequires(c, UnixCli, DaemonIsLinux) // uses os.Symlink: not implemented in windows at the time of writing (go-1.4.2)
3845
-
3846
-	name := "testbuilddockerfileoutsidecontext"
3847
-	tmpdir, err := ioutil.TempDir("", name)
3848
-	c.Assert(err, check.IsNil)
3849
-	defer os.RemoveAll(tmpdir)
3850
-	ctx := filepath.Join(tmpdir, "context")
3851
-	if err := os.MkdirAll(ctx, 0755); err != nil {
3852
-		c.Fatal(err)
3853
-	}
3854
-	if err := ioutil.WriteFile(filepath.Join(ctx, "Dockerfile"), []byte("FROM scratch\nENV X Y"), 0644); err != nil {
3855
-		c.Fatal(err)
3856
-	}
3857
-	wd, err := os.Getwd()
3858
-	if err != nil {
3859
-		c.Fatal(err)
3860
-	}
3861
-	defer os.Chdir(wd)
3862
-	if err := os.Chdir(ctx); err != nil {
3863
-		c.Fatal(err)
3864
-	}
3865
-	if err := ioutil.WriteFile(filepath.Join(tmpdir, "outsideDockerfile"), []byte("FROM scratch\nENV x y"), 0644); err != nil {
3866
-		c.Fatal(err)
3867
-	}
3868
-	if err := os.Symlink(filepath.Join("..", "outsideDockerfile"), filepath.Join(ctx, "dockerfile1")); err != nil {
3869
-		c.Fatal(err)
3870
-	}
3871
-	if err := os.Symlink(filepath.Join(tmpdir, "outsideDockerfile"), filepath.Join(ctx, "dockerfile2")); err != nil {
3872
-		c.Fatal(err)
3873
-	}
3874
-
3875
-	for _, dockerfilePath := range []string{
3876
-		filepath.Join("..", "outsideDockerfile"),
3877
-		filepath.Join(ctx, "dockerfile1"),
3878
-		filepath.Join(ctx, "dockerfile2"),
3879
-	} {
3880
-		result := dockerCmdWithResult("build", "-t", name, "--no-cache", "-f", dockerfilePath, ".")
3881
-		result.Assert(c, icmd.Expected{
3882
-			Err:      "must be within the build context",
3883
-			ExitCode: 1,
3884
-		})
3885
-		deleteImages(name)
3886
-	}
3887
-
3888
-	os.Chdir(tmpdir)
3889
-
3890
-	// Path to Dockerfile should be resolved relative to working directory, not relative to context.
3891
-	// There is a Dockerfile in the context, but since there is no Dockerfile in the current directory, the following should fail
3892
-	out, _, err := dockerCmdWithError("build", "-t", name, "--no-cache", "-f", "Dockerfile", ctx)
3893
-	if err == nil {
3894
-		c.Fatalf("Expected error. Out: %s", out)
3895
-	}
3896
-}
3897
-
3898 3843
 // FIXME(vdemeester) should be a unit test
3899 3844
 func (s *DockerSuite) TestBuildSpaces(c *check.C) {
3900 3845
 	// Test to make sure that leading/trailing spaces on a command
... ...
@@ -4186,6 +4083,7 @@ func (s *DockerTrustSuite) TestTrustedBuildUntrustedTag(c *check.C) {
4186 4186
 	})
4187 4187
 }
4188 4188
 
4189
+// FIXME(vdemeester) should migrate to docker/cli e2e tests
4189 4190
 func (s *DockerTrustSuite) TestBuildContextDirIsSymlink(c *check.C) {
4190 4191
 	testRequires(c, DaemonIsLinux)
4191 4192
 	tempDir, err := ioutil.TempDir("", "test-build-dir-is-symlink-")
... ...
@@ -5130,6 +5028,7 @@ func (s *DockerSuite) TestBuildCacheRootSource(c *check.C) {
5130 5130
 }
5131 5131
 
5132 5132
 // #19375
5133
+// FIXME(vdemeester) should migrate to docker/cli tests
5133 5134
 func (s *DockerSuite) TestBuildFailsGitNotCallable(c *check.C) {
5134 5135
 	buildImage("gitnotcallable", cli.WithEnvironmentVariables("PATH="),
5135 5136
 		build.WithContextPath("github.com/docker/v1.10-migrator.git")).Assert(c, icmd.Expected{
... ...
@@ -6447,6 +6346,7 @@ CMD echo foo
6447 6447
 	c.Assert(strings.TrimSpace(out), checker.Equals, `["/bin/sh","-c","echo foo"]`)
6448 6448
 }
6449 6449
 
6450
+// FIXME(vdemeester) should migrate to docker/cli tests
6450 6451
 func (s *DockerSuite) TestBuildIidFile(c *check.C) {
6451 6452
 	tmpDir, err := ioutil.TempDir("", "TestBuildIidFile")
6452 6453
 	if err != nil {
... ...
@@ -6471,6 +6371,7 @@ ENV BAR BAZ`),
6471 6471
 	c.Assert(d.String(), checker.Equals, getIDByName(c, name))
6472 6472
 }
6473 6473
 
6474
+// FIXME(vdemeester) should migrate to docker/cli tests
6474 6475
 func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *check.C) {
6475 6476
 	tmpDir, err := ioutil.TempDir("", "TestBuildIidFileCleanupOnFail")
6476 6477
 	if err != nil {
... ...
@@ -6493,6 +6394,7 @@ func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *check.C) {
6493 6493
 	c.Assert(os.IsNotExist(err), check.Equals, true)
6494 6494
 }
6495 6495
 
6496
+// FIXME(vdemeester) should migrate to docker/cli tests
6496 6497
 func (s *DockerSuite) TestBuildIidFileSquash(c *check.C) {
6497 6498
 	testRequires(c, ExperimentalDaemon)
6498 6499
 	tmpDir, err := ioutil.TempDir("", "TestBuildIidFileSquash")