@@ -32,10 +32,11 @@ func TestRunBuildOnce(t *testing.T) {
3232 c := NewParallelCLI (t )
3333
3434 t .Run ("dependency with pull_policy build is built only once" , func (t * testing.T ) {
35- res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
35+ projectName := "e2e-run-build-once-single"
36+ res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
3637 res .Assert (t , icmd .Success )
3738
38- res = c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once.yaml" , "run" , "--rm" , "curl" )
39+ res = c .RunDockerComposeCmd (t , "-p" , projectName , "- f" , "./fixtures/run-test/build-once.yaml" , "run" , "--rm" , "curl" )
3940 res .Assert (t , icmd .Success )
4041
4142 // Count how many times nginx was built by looking for its unique RUN command output
@@ -45,14 +46,15 @@ func TestRunBuildOnce(t *testing.T) {
4546 assert .Equal (t , nginxBuilds , 1 , "nginx dependency should build once, but built %d times" , nginxBuilds )
4647 assert .Assert (t , strings .Contains (res .Combined (), "curl service" ))
4748
48- c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once.yaml" , "down" , "--remove-orphans" )
49+ c .RunDockerComposeCmd (t , "-p" , projectName , "- f" , "./fixtures/run-test/build-once.yaml" , "down" , "--remove-orphans" )
4950 })
5051
5152 t .Run ("nested dependencies build only once each" , func (t * testing.T ) {
52- res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once-nested.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
53+ projectName := "e2e-run-build-once-nested"
54+ res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-nested.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
5355 res .Assert (t , icmd .Success )
5456
55- res = c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once-nested.yaml" , "run" , "--rm" , "app" )
57+ res = c .RunDockerComposeCmd (t , "-p" , projectName , "- f" , "./fixtures/run-test/build-once-nested.yaml" , "run" , "--rm" , "app" )
5658 res .Assert (t , icmd .Success )
5759
5860 output := res .Combined ()
@@ -67,21 +69,22 @@ func TestRunBuildOnce(t *testing.T) {
6769 assert .Equal (t , appBuilds , 1 , "app should build once, built %d times" , appBuilds )
6870 assert .Assert (t , strings .Contains (output , "App running" ))
6971
70- c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once-nested.yaml" , "down" , "--remove-orphans" )
72+ c .RunDockerComposeCmd (t , "-p" , projectName , "- f" , "./fixtures/run-test/build-once-nested.yaml" , "down" , "--remove-orphans" )
7173 })
7274
7375 t .Run ("service with no dependencies builds once" , func (t * testing.T ) {
74- res := c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
76+ projectName := "e2e-run-build-once-no-deps"
77+ res := c .RunDockerComposeCmd (t , "-p" , projectName , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "down" , "--rmi" , "local" , "--remove-orphans" )
7578 res .Assert (t , icmd .Success )
7679
77- res = c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "run" , "--rm" , "simple" )
80+ res = c .RunDockerComposeCmd (t , "-p" , projectName , "- f" , "./fixtures/run-test/build-once-no-deps.yaml" , "run" , "--rm" , "simple" )
7881 res .Assert (t , icmd .Success )
7982
8083 // Should build exactly once
8184 simpleBuilds := strings .Count (res .Combined (), "Simple service built at" )
8285 assert .Equal (t , simpleBuilds , 1 , "simple should build once, built %d times" , simpleBuilds )
8386 assert .Assert (t , strings .Contains (res .Combined (), "Simple service" ))
8487
85- c .RunDockerComposeCmd (t , "-f" , "./fixtures/run-test/build-once-no-deps.yaml" , "down" , "--remove-orphans" )
88+ c .RunDockerComposeCmd (t , "-p" , projectName , "- f" , "./fixtures/run-test/build-once-no-deps.yaml" , "down" , "--remove-orphans" )
8689 })
8790}
0 commit comments