Browse Source

Merge pull request #8953 from ulyssessouza/test-multiargs

Add multiargs build e2e tests
Mathieu Champlon 4 năm trước cách đây
mục cha
commit
32005b0bfe

+ 13 - 0
pkg/e2e/compose_build_test.go

@@ -66,6 +66,19 @@ func TestLocalComposeBuild(t *testing.T) {
 		res.Assert(t, icmd.Expected{Out: `"FOO": "BAR"`})
 	})
 
+	t.Run("build with multiple build-args ", func(t *testing.T) {
+		// ensure local test run does not reuse previously build image
+		c.RunDockerOrExitError("rmi", "-f", "multi-args_multiargs")
+		cmd := c.NewDockerCmd("compose", "--project-directory", "fixtures/build-test/multi-args", "build")
+
+		icmd.RunCmd(cmd, func(cmd *icmd.Cmd) {
+			cmd.Env = append(cmd.Env, "DOCKER_BUILDKIT=0")
+		})
+
+		res := c.RunDockerCmd("image", "inspect", "multi-args_multiargs")
+		res.Assert(t, icmd.Expected{Out: `"RESULT": "SUCCESS"`})
+	})
+
 	t.Run("build as part of up", func(t *testing.T) {
 		c.RunDockerOrExitError("rmi", "build-test_nginx")
 		c.RunDockerOrExitError("rmi", "custom-nginx")

+ 19 - 0
pkg/e2e/fixtures/build-test/multi-args/Dockerfile

@@ -0,0 +1,19 @@
+#   Copyright 2020 Docker Compose CLI authors
+
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+
+#       http://www.apache.org/licenses/LICENSE-2.0
+
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+ARG IMAGE=666
+ARG TAG=666
+
+FROM ${IMAGE}:${TAG}
+RUN echo "SUCCESS"

+ 9 - 0
pkg/e2e/fixtures/build-test/multi-args/compose.yaml

@@ -0,0 +1,9 @@
+services:
+  multiargs:
+    build:
+      context: .
+      args:
+        IMAGE: alpine
+        TAG: latest
+      labels:
+        - RESULT=SUCCESS

+ 2 - 2
pkg/e2e/framework.go

@@ -104,9 +104,9 @@ func newE2eCLI(t *testing.T, binDir string) *E2eCLI {
 }
 
 func dirContents(dir string) []string {
-	res := []string{}
+	var res []string
 	_ = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
-		res = append(res, filepath.Join(dir, path))
+		res = append(res, path)
 		return nil
 	})
 	return res