@@ -24,23 +24,19 @@ import (
2424 "testing"
2525
2626 "gotest.tools/v3/assert"
27- "gotest.tools/v3/icmd"
2827)
2928
3029// TestRunBuildOnce tests that services with pull_policy: build are only built once
3130// when using 'docker compose run', even when they are dependencies.
3231// This addresses a bug where dependencies were built twice: once in startDependencies
3332// and once in ensureImagesExists.
3433func TestRunBuildOnce (t * testing.T ) {
35- c := NewCLI (t )
34+ c := NewParallelCLI (t )
3635
3736 t .Run ("dependency with pull_policy build is built only once" , func (t * testing.T ) {
3837 projectName := randomProjectName ("build-once" )
39- res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
40- res .Assert (t , icmd .Success )
41-
42- res = c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once.yaml" , "run" , "--build" , "--rm" , "curl" )
43- res .Assert (t , icmd .Success )
38+ _ = c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" , "-v" )
39+ res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once.yaml" , "--verbose" , "run" , "--build" , "--rm" , "curl" )
4440
4541 // Count how many times nginx was built by looking for its unique RUN command output
4642 nginxBuilds := strings .Count (res .Combined (), "Building nginx at" )
@@ -55,9 +51,7 @@ func TestRunBuildOnce(t *testing.T) {
5551 t .Run ("nested dependencies build only once each" , func (t * testing.T ) {
5652 projectName := randomProjectName ("build-nested" )
5753 _ = c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-nested.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" , "-v" )
58-
5954 res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-nested.yaml" , "--verbose" , "run" , "--build" , "--rm" , "app" )
60- res .Assert (t , icmd .Success )
6155
6256 output := res .Combined ()
6357
@@ -79,11 +73,8 @@ func TestRunBuildOnce(t *testing.T) {
7973
8074 t .Run ("service with no dependencies builds once" , func (t * testing.T ) {
8175 projectName := randomProjectName ("build-simple" )
82- res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
83- res .Assert (t , icmd .Success )
84-
85- res = c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "run" , "--build" , "--rm" , "simple" )
86- res .Assert (t , icmd .Success )
76+ _ = c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
77+ res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "run" , "--build" , "--rm" , "simple" )
8778
8879 // Should build exactly once
8980 simpleBuilds := strings .Count (res .Combined (), "Simple service built at" )
0 commit comments