@@ -28,55 +28,55 @@ import (
28
28
)
29
29
30
30
func TestLocalComposeBuild (t * testing.T ) {
31
- c := NewParallelE2eCLI ( t , binDir )
31
+ c := NewParallelCLI ( t )
32
32
33
33
t .Run ("build named and unnamed images" , func (t * testing.T ) {
34
34
// 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" )
37
37
38
- res := c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "build" )
38
+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "build" )
39
39
40
40
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" )
43
43
})
44
44
45
45
t .Run ("build with build-arg" , func (t * testing.T ) {
46
46
// 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" )
49
49
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" )
51
51
52
- res := c .RunDockerCmd ("image" , "inspect" , "build-test_nginx" )
52
+ res := c .RunDockerCmd (t , "image" , "inspect" , "build-test_nginx" )
53
53
res .Assert (t , icmd.Expected {Out : `"FOO": "BAR"` })
54
54
})
55
55
56
56
t .Run ("build with build-arg set by env" , func (t * testing.T ) {
57
57
// 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" )
60
60
61
61
icmd .RunCmd (c .NewDockerCmd ("compose" , "--project-directory" , "fixtures/build-test" , "build" , "--build-arg" , "FOO" ),
62
62
func (cmd * icmd.Cmd ) {
63
63
cmd .Env = append (cmd .Env , "FOO=BAR" )
64
64
})
65
65
66
- res := c .RunDockerCmd ("image" , "inspect" , "build-test_nginx" )
66
+ res := c .RunDockerCmd (t , "image" , "inspect" , "build-test_nginx" )
67
67
res .Assert (t , icmd.Expected {Out : `"FOO": "BAR"` })
68
68
})
69
69
70
70
t .Run ("build with multiple build-args " , func (t * testing.T ) {
71
71
// 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" )
73
73
cmd := c .NewDockerCmd ("compose" , "--project-directory" , "fixtures/build-test/multi-args" , "build" )
74
74
75
75
icmd .RunCmd (cmd , func (cmd * icmd.Cmd ) {
76
76
cmd .Env = append (cmd .Env , "DOCKER_BUILDKIT=0" )
77
77
})
78
78
79
- res := c .RunDockerCmd ("image" , "inspect" , "multi-args_multiargs" )
79
+ res := c .RunDockerCmd (t , "image" , "inspect" , "multi-args_multiargs" )
80
80
res .Assert (t , icmd.Expected {Out : `"RESULT": "SUCCESS"` })
81
81
})
82
82
@@ -86,7 +86,7 @@ func TestLocalComposeBuild(t *testing.T) {
86
86
os .Unsetenv ("SSH_AUTH_SOCK" ) //nolint:errcheck
87
87
defer os .Setenv ("SSH_AUTH_SOCK" , defaultSSHAUTHSOCK ) //nolint:errcheck
88
88
89
- res := c .RunDockerComposeCmdNoCheck ("--project-directory" , "fixtures/build-test" , "build" , "--ssh" , "" )
89
+ res := c .RunDockerComposeCmdNoCheck (t , "--project-directory" , "fixtures/build-test" , "build" , "--ssh" , "" )
90
90
res .Assert (t , icmd.Expected {
91
91
ExitCode : 1 ,
92
92
Err : "invalid empty ssh agent socket: make sure SSH_AUTH_SOCK is set" ,
@@ -95,24 +95,24 @@ func TestLocalComposeBuild(t *testing.T) {
95
95
})
96
96
97
97
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" )
99
99
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" )
102
102
})
103
103
104
104
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" )
106
106
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" ,
108
108
"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" )
110
110
})
111
111
112
112
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" )
114
114
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" ,
116
116
"--project-directory" , "fixtures/build-test/ssh" , "build" , "--no-cache" , "--ssh" ,
117
117
"wrong-ssh=./fixtures/build-test/ssh/fake_rsa" )
118
118
res .Assert (t , icmd.Expected {
@@ -122,22 +122,22 @@ func TestLocalComposeBuild(t *testing.T) {
122
122
})
123
123
124
124
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" )
126
126
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" )
128
128
t .Cleanup (func () {
129
- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test/ssh" , "down" )
129
+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test/ssh" , "down" )
130
130
})
131
- c .RunDockerCmd ("image" , "inspect" , "build-test-ssh" )
131
+ c .RunDockerCmd (t , "image" , "inspect" , "build-test-ssh" )
132
132
})
133
133
134
134
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" )
137
137
138
- res := c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "up" , "-d" )
138
+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "up" , "-d" )
139
139
t .Cleanup (func () {
140
- c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test" , "down" )
140
+ c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test" , "down" )
141
141
})
142
142
143
143
res .Assert (t , icmd.Expected {Out : "COPY static /usr/share/nginx/html" })
@@ -146,53 +146,53 @@ func TestLocalComposeBuild(t *testing.T) {
146
146
output := HTTPGetWithRetry (t , "http://localhost:8070" , http .StatusOK , 2 * time .Second , 20 * time .Second )
147
147
assert .Assert (t , strings .Contains (output , "Hello from Nginx container" ))
148
148
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" )
151
151
})
152
152
153
153
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" )
155
155
156
156
assert .Assert (t , ! strings .Contains (res .Stdout (), "COPY static" ), res .Stdout ())
157
157
})
158
158
159
159
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" )
161
161
162
162
res .Assert (t , icmd.Expected {Out : "COPY static /usr/share/nginx/html" })
163
163
res .Assert (t , icmd.Expected {Out : "COPY static2 /usr/share/nginx/html" })
164
164
})
165
165
166
166
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" )
170
170
})
171
171
}
172
172
173
173
func TestBuildSecrets (t * testing.T ) {
174
- c := NewParallelE2eCLI ( t , binDir )
174
+ c := NewParallelCLI ( t )
175
175
176
176
t .Run ("build with secrets" , func (t * testing.T ) {
177
177
// 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" )
179
179
180
- res := c .RunDockerComposeCmd ("--project-directory" , "fixtures/build-test/secrets" , "build" )
180
+ res := c .RunDockerComposeCmd (t , "--project-directory" , "fixtures/build-test/secrets" , "build" )
181
181
res .Assert (t , icmd .Success )
182
182
})
183
183
}
184
184
185
185
func TestBuildTags (t * testing.T ) {
186
- c := NewParallelE2eCLI ( t , binDir )
186
+ c := NewParallelCLI ( t )
187
187
188
188
t .Run ("build with tags" , func (t * testing.T ) {
189
189
190
190
// 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" )
192
192
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" )
194
194
195
- res := c .RunDockerCmd ("image" , "inspect" , "build-test-tags" )
195
+ res := c .RunDockerCmd (t , "image" , "inspect" , "build-test-tags" )
196
196
expectedOutput := `"RepoTags": [
197
197
"docker/build-test-tags:1.0.0",
198
198
"build-test-tags:latest",
0 commit comments