@@ -153,6 +153,60 @@ var _ = Describe("Build API", func() {
153
153
Expect (err ).Should (BeNil ())
154
154
Expect (buildOption .Rm ).Should (BeTrue ())
155
155
})
156
+ It ("should set the q query param" , func () {
157
+ ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
158
+ req = httptest .NewRequest (http .MethodPost , "/build?q=false" , nil )
159
+ buildOption , err := h .getBuildOptions (rr , req , stream )
160
+ Expect (err ).Should (BeNil ())
161
+ Expect (buildOption .Quiet ).Should (BeFalse ())
162
+ })
163
+ It ("should set the nocache query param" , func () {
164
+ ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
165
+ req = httptest .NewRequest (http .MethodPost , "/build?nocache=true" , nil )
166
+ buildOption , err := h .getBuildOptions (rr , req , stream )
167
+ Expect (err ).Should (BeNil ())
168
+ Expect (buildOption .NoCache ).Should (BeTrue ())
169
+ })
170
+ It ("should set the CacheFrom query param" , func () {
171
+ ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
172
+ req = httptest .NewRequest (http .MethodPost , "/build?cachefrom={\" image1\" :\" tag1\" ,\" image2\" :\" tag2\" }" , nil )
173
+ buildOption , err := h .getBuildOptions (rr , req , stream )
174
+ Expect (err ).Should (BeNil ())
175
+ Expect (buildOption .CacheFrom ).Should (ContainElements ("image1=tag1" , "image2=tag2" ))
176
+ })
177
+
178
+ It ("should set the BuildArgs query param" , func () {
179
+ ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
180
+ req = httptest .NewRequest (http .MethodPost , "/build?buildargs={\" ARG1\" :\" value1\" ,\" ARG2\" :\" value2\" }" , nil )
181
+ buildOption , err := h .getBuildOptions (rr , req , stream )
182
+ Expect (err ).Should (BeNil ())
183
+ Expect (buildOption .BuildArgs ).Should (ContainElements ("ARG1=value1" , "ARG2=value2" ))
184
+ })
185
+
186
+ It ("should set the Label query param" , func () {
187
+ ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
188
+ req = httptest .NewRequest (http .MethodPost , "/build?labels={\" LABEL1\" :\" value1\" ,\" LABEL2\" :\" value2\" }" , nil )
189
+ buildOption , err := h .getBuildOptions (rr , req , stream )
190
+ Expect (err ).Should (BeNil ())
191
+ Expect (buildOption .Label ).Should (ContainElements ("LABEL1=value1" , "LABEL2=value2" ))
192
+ })
193
+
194
+ It ("should set the NetworkMode query param" , func () {
195
+ ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
196
+ req = httptest .NewRequest (http .MethodPost , "/build?networkmode=host" , nil )
197
+ buildOption , err := h .getBuildOptions (rr , req , stream )
198
+ Expect (err ).Should (BeNil ())
199
+ Expect (buildOption .NetworkMode ).Should (Equal ("host" ))
200
+ })
201
+
202
+ It ("should set the Output query param" , func () {
203
+ ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
204
+ req = httptest .NewRequest (http .MethodPost , "/build?output=type=docker" , nil )
205
+ buildOption , err := h .getBuildOptions (rr , req , stream )
206
+ Expect (err ).Should (BeNil ())
207
+ Expect (buildOption .Output ).Should (Equal ("type=docker" ))
208
+ })
209
+
156
210
It ("should set all the default value for the query param" , func () {
157
211
ncBuildSvc .EXPECT ().GetBuildkitHost ().Return ("mocked-value" , nil ).AnyTimes ()
158
212
req = httptest .NewRequest (http .MethodPost , "/build" , nil )
@@ -162,6 +216,13 @@ var _ = Describe("Build API", func() {
162
216
Expect (buildOption .Platform ).Should (HaveLen (0 ))
163
217
Expect (buildOption .File ).Should (Equal ("Dockerfile" ))
164
218
Expect (buildOption .Rm ).Should (BeTrue ())
219
+ Expect (buildOption .Quiet ).Should (BeTrue ())
220
+ Expect (buildOption .NoCache ).Should (BeFalse ())
221
+ Expect (buildOption .CacheFrom ).Should (BeEmpty ())
222
+ Expect (buildOption .BuildArgs ).Should (BeEmpty ())
223
+ Expect (buildOption .Label ).Should (BeEmpty ())
224
+ Expect (buildOption .NetworkMode ).Should (BeEmpty ())
225
+ Expect (buildOption .Output ).Should (BeEmpty ())
165
226
})
166
227
})
167
228
})
0 commit comments