@@ -28,55 +28,55 @@ import (
2828)
2929
3030func TestLocalComposeBuild (t * testing.T ) {
31- c := NewParallelE2eCLI ( t , binDir )
31+ c := NewParallelCLI ( t )
3232
3333 t .Run ("build named and unnamed images" , func (t * testing.T ) {
3434 // ensure local test run does not reuse previously build image
35- c .RunDockerOrExitError ("rmi" , "build-test_nginx" )
36- c .RunDockerOrExitError ("rmi" , "custom-nginx" )
35+ c .RunDockerOrExitError (t , "rmi" , "build-test_nginx" )
36+ c .RunDockerOrExitError (t , "rmi" , "custom-nginx" )
3737
38- res := c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "build" )
38+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "build" )
3939
4040 res .Assert (t , icmd.Expected {Out : "COPY static /usr/share/nginx/html" })
41- c .RunDockerCmd ("image" , "inspect" , "build-test_nginx" )
42- c .RunDockerCmd ("image" , "inspect" , "custom-nginx" )
41+ c .RunDockerCmd (t , "image" , "inspect" , "build-test_nginx" )
42+ c .RunDockerCmd (t , "image" , "inspect" , "custom-nginx" )
4343 })
4444
4545 t .Run ("build with build-arg" , func (t * testing.T ) {
4646 // ensure local test run does not reuse previously build image
47- c .RunDockerOrExitError ("rmi" , "build-test_nginx" )
48- c .RunDockerOrExitError ("rmi" , "custom-nginx" )
47+ c .RunDockerOrExitError (t , "rmi" , "build-test_nginx" )
48+ c .RunDockerOrExitError (t , "rmi" , "custom-nginx" )
4949
50- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "build" , "--build-arg" , "FOO=BAR" )
50+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "build" , "--build-arg" , "FOO=BAR" )
5151
52- res := c .RunDockerCmd ("image" , "inspect" , "build-test_nginx" )
52+ res := c .RunDockerCmd (t , "image" , "inspect" , "build-test_nginx" )
5353 res .Assert (t , icmd.Expected {Out : `"FOO": "BAR"` })
5454 })
5555
5656 t .Run ("build with build-arg set by env" , func (t * testing.T ) {
5757 // ensure local test run does not reuse previously build image
58- c .RunDockerOrExitError ("rmi" , "build-test_nginx" )
59- c .RunDockerOrExitError ("rmi" , "custom-nginx" )
58+ c .RunDockerOrExitError (t , "rmi" , "build-test_nginx" )
59+ c .RunDockerOrExitError (t , "rmi" , "custom-nginx" )
6060
6161 icmd .RunCmd (c .NewDockerCmd ("compose" , "--project-directory" , "fixtures/build-test" , "build" , "--build-arg" , "FOO" ),
6262 func (cmd * icmd.Cmd ) {
6363 cmd .Env = append (cmd .Env , "FOO=BAR" )
6464 })
6565
66- res := c .RunDockerCmd ("image" , "inspect" , "build-test_nginx" )
66+ res := c .RunDockerCmd (t , "image" , "inspect" , "build-test_nginx" )
6767 res .Assert (t , icmd.Expected {Out : `"FOO": "BAR"` })
6868 })
6969
7070 t .Run ("build with multiple build-args " , func (t * testing.T ) {
7171 // ensure local test run does not reuse previously build image
72- c .RunDockerOrExitError ("rmi" , "-f" , "multi-args_multiargs" )
72+ c .RunDockerOrExitError (t , "rmi" , "-f" , "multi-args_multiargs" )
7373 cmd := c .NewDockerCmd ("compose" , "--project-directory" , "fixtures/build-test/multi-args" , "build" )
7474
7575 icmd .RunCmd (cmd , func (cmd * icmd.Cmd ) {
7676 cmd .Env = append (cmd .Env , "DOCKER_BUILDKIT=0" )
7777 })
7878
79- res := c .RunDockerCmd ("image" , "inspect" , "multi-args_multiargs" )
79+ res := c .RunDockerCmd (t , "image" , "inspect" , "multi-args_multiargs" )
8080 res .Assert (t , icmd.Expected {Out : `"RESULT": "SUCCESS"` })
8181 })
8282
@@ -86,7 +86,7 @@ func TestLocalComposeBuild(t *testing.T) {
8686 os .Unsetenv ("SSH_AUTH_SOCK" ) //nolint:errcheck
8787 defer os .Setenv ("SSH_AUTH_SOCK" , defaultSSHAUTHSOCK ) //nolint:errcheck
8888
89- res := c .RunDockerComposeCmdNoCheck ("--project-directory" , "fixtures/build-test" , "build" , "--ssh" , "" )
89+ res := c .RunDockerComposeCmdNoCheck (t , "--project-directory" , "fixtures/build-test" , "build" , "--ssh" , "" )
9090 res .Assert (t , icmd.Expected {
9191 ExitCode : 1 ,
9292 Err : "invalid empty ssh agent socket: make sure SSH_AUTH_SOCK is set" ,
@@ -95,24 +95,24 @@ func TestLocalComposeBuild(t *testing.T) {
9595 })
9696
9797 t .Run ("build succeed with ssh from Compose file" , func (t * testing.T ) {
98- c .RunDockerOrExitError ("rmi" , "build-test-ssh" )
98+ c .RunDockerOrExitError (t , "rmi" , "build-test-ssh" )
9999
100- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test/ssh" , "build" )
101- c .RunDockerCmd ("image" , "inspect" , "build-test-ssh" )
100+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test/ssh" , "build" )
101+ c .RunDockerCmd (t , "image" , "inspect" , "build-test-ssh" )
102102 })
103103
104104 t .Run ("build succeed with ssh from CLI" , func (t * testing.T ) {
105- c .RunDockerOrExitError ("rmi" , "build-test-ssh" )
105+ c .RunDockerOrExitError (t , "rmi" , "build-test-ssh" )
106106
107- c .RunDockerComposeCmd ("-f" , "fixtures/build-test/ssh/compose-without-ssh.yaml" , "--project-directory" ,
107+ c .RunDockerComposeCmd (t , "-f" , "fixtures/build-test/ssh/compose-without-ssh.yaml" , "--project-directory" ,
108108 "fixtures/build-test/ssh" , "build" , "--no-cache" , "--ssh" , "fake-ssh=./fixtures/build-test/ssh/fake_rsa" )
109- c .RunDockerCmd ("image" , "inspect" , "build-test-ssh" )
109+ c .RunDockerCmd (t , "image" , "inspect" , "build-test-ssh" )
110110 })
111111
112112 t .Run ("build failed with wrong ssh key id from CLI" , func (t * testing.T ) {
113- c .RunDockerOrExitError ("rmi" , "build-test-ssh" )
113+ c .RunDockerOrExitError (t , "rmi" , "build-test-ssh" )
114114
115- res := c .RunDockerComposeCmdNoCheck ("-f" , "fixtures/build-test/ssh/compose-without-ssh.yaml" ,
115+ res := c .RunDockerComposeCmdNoCheck (t , "-f" , "fixtures/build-test/ssh/compose-without-ssh.yaml" ,
116116 "--project-directory" , "fixtures/build-test/ssh" , "build" , "--no-cache" , "--ssh" ,
117117 "wrong-ssh=./fixtures/build-test/ssh/fake_rsa" )
118118 res .Assert (t , icmd.Expected {
@@ -122,22 +122,22 @@ func TestLocalComposeBuild(t *testing.T) {
122122 })
123123
124124 t .Run ("build succeed as part of up with ssh from Compose file" , func (t * testing.T ) {
125- c .RunDockerOrExitError ("rmi" , "build-test-ssh" )
125+ c .RunDockerOrExitError (t , "rmi" , "build-test-ssh" )
126126
127- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test/ssh" , "up" , "-d" , "--build" )
127+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test/ssh" , "up" , "-d" , "--build" )
128128 t .Cleanup (func () {
129- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test/ssh" , "down" )
129+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test/ssh" , "down" )
130130 })
131- c .RunDockerCmd ("image" , "inspect" , "build-test-ssh" )
131+ c .RunDockerCmd (t , "image" , "inspect" , "build-test-ssh" )
132132 })
133133
134134 t .Run ("build as part of up" , func (t * testing.T ) {
135- c .RunDockerOrExitError ("rmi" , "build-test_nginx" )
136- c .RunDockerOrExitError ("rmi" , "custom-nginx" )
135+ c .RunDockerOrExitError (t , "rmi" , "build-test_nginx" )
136+ c .RunDockerOrExitError (t , "rmi" , "custom-nginx" )
137137
138- res := c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "up" , "-d" )
138+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "up" , "-d" )
139139 t .Cleanup (func () {
140- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "down" )
140+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "down" )
141141 })
142142
143143 res .Assert (t , icmd.Expected {Out : "COPY static /usr/share/nginx/html" })
@@ -146,53 +146,53 @@ func TestLocalComposeBuild(t *testing.T) {
146146 output := HTTPGetWithRetry (t , "http://localhost:8070" , http .StatusOK , 2 * time .Second , 20 * time .Second )
147147 assert .Assert (t , strings .Contains (output , "Hello from Nginx container" ))
148148
149- c .RunDockerCmd ("image" , "inspect" , "build-test_nginx" )
150- c .RunDockerCmd ("image" , "inspect" , "custom-nginx" )
149+ c .RunDockerCmd (t , "image" , "inspect" , "build-test_nginx" )
150+ c .RunDockerCmd (t , "image" , "inspect" , "custom-nginx" )
151151 })
152152
153153 t .Run ("no rebuild when up again" , func (t * testing.T ) {
154- res := c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "up" , "-d" )
154+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "up" , "-d" )
155155
156156 assert .Assert (t , ! strings .Contains (res .Stdout (), "COPY static" ), res .Stdout ())
157157 })
158158
159159 t .Run ("rebuild when up --build" , func (t * testing.T ) {
160- res := c .RunDockerComposeCmd ("--workdir" , "fixtures/build-test" , "up" , "-d" , "--build" )
160+ res := c .RunDockerComposeCmd (t , "--workdir" , "fixtures/build-test" , "up" , "-d" , "--build" )
161161
162162 res .Assert (t , icmd.Expected {Out : "COPY static /usr/share/nginx/html" })
163163 res .Assert (t , icmd.Expected {Out : "COPY static2 /usr/share/nginx/html" })
164164 })
165165
166166 t .Run ("cleanup build project" , func (t * testing.T ) {
167- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "down" )
168- c .RunDockerCmd ("rmi" , "build-test_nginx" )
169- c .RunDockerCmd ("rmi" , "custom-nginx" )
167+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "down" )
168+ c .RunDockerCmd (t , "rmi" , "build-test_nginx" )
169+ c .RunDockerCmd (t , "rmi" , "custom-nginx" )
170170 })
171171}
172172
173173func TestBuildSecrets (t * testing.T ) {
174- c := NewParallelE2eCLI ( t , binDir )
174+ c := NewParallelCLI ( t )
175175
176176 t .Run ("build with secrets" , func (t * testing.T ) {
177177 // ensure local test run does not reuse previously build image
178- c .RunDockerOrExitError ("rmi" , "build-test-secret" )
178+ c .RunDockerOrExitError (t , "rmi" , "build-test-secret" )
179179
180- res := c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test/secrets" , "build" )
180+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test/secrets" , "build" )
181181 res .Assert (t , icmd .Success )
182182 })
183183}
184184
185185func TestBuildTags (t * testing.T ) {
186- c := NewParallelE2eCLI ( t , binDir )
186+ c := NewParallelCLI ( t )
187187
188188 t .Run ("build with tags" , func (t * testing.T ) {
189189
190190 // ensure local test run does not reuse previously build image
191- c .RunDockerOrExitError ("rmi" , "build-test-tags" )
191+ c .RunDockerOrExitError (t , "rmi" , "build-test-tags" )
192192
193- c .RunDockerComposeCmd ("--project-directory" , "./fixtures/build-test/tags" , "build" , "--no-cache" )
193+ c .RunDockerComposeCmd (t , "--project-directory" , "./fixtures/build-test/tags" , "build" , "--no-cache" )
194194
195- res := c .RunDockerCmd ("image" , "inspect" , "build-test-tags" )
195+ res := c .RunDockerCmd (t , "image" , "inspect" , "build-test-tags" )
196196 expectedOutput := `"RepoTags": [
197197 "docker/build-test-tags:1.0.0",
198198 "build-test-tags:latest",
0 commit comments