@@ -194,7 +194,7 @@ func TestBuilder_Reason(t *testing.T) {
194
194
withWorkspaceTags (inactiveVersionID , nil ),
195
195
196
196
// Outputs
197
- expectProvisionerJob (func (job database.InsertProvisionerJobParams ) {
197
+ expectProvisionerJob (func (_ database.InsertProvisionerJobParams ) {
198
198
}),
199
199
withInTx ,
200
200
expectBuild (func (bld database.InsertWorkspaceBuildParams ) {
@@ -254,20 +254,33 @@ func TestBuilder_ActiveVersion(t *testing.T) {
254
254
func TestWorkspaceBuildWithTags (t * testing.T ) {
255
255
t .Parallel ()
256
256
257
+ asrt := assert .New (t )
257
258
req := require .New (t )
258
259
259
260
workspaceTags := []database.TemplateVersionWorkspaceTag {
261
+ {
262
+ Key : "fruits_tag" ,
263
+ Value : "data.coder_parameter.number_of_apples.value + data.coder_parameter.number_of_oranges.value" ,
264
+ },
260
265
{
261
266
Key : "cluster_tag" ,
262
- Value : "developers" ,
267
+ Value : `"best_developers"` ,
263
268
},
264
269
{
265
270
Key : "project_tag" ,
266
271
Value : `"${data.coder_parameter.project.value}+12345"` ,
267
272
},
268
273
{
269
274
Key : "team_tag" ,
270
- Value : `"data.coder_parameter.team.value` ,
275
+ Value : `data.coder_parameter.team.value` ,
276
+ },
277
+ {
278
+ Key : "yes_or_no" ,
279
+ Value : `data.coder_parameter.is_debug_build.value` ,
280
+ },
281
+ {
282
+ Key : "actually_no" ,
283
+ Value : `!data.coder_parameter.is_debug_build.value` ,
271
284
},
272
285
{
273
286
Key : "is_debug_build" ,
@@ -279,13 +292,15 @@ func TestWorkspaceBuildWithTags(t *testing.T) {
279
292
// Parameters can be mutable although it is discouraged as the workspace can be moved between provisioner nodes.
280
293
{Name : "project" , Description : "This is first parameter" , Mutable : true , Options : json .RawMessage ("[]" )},
281
294
{Name : "team" , Description : "This is second parameter" , Mutable : true , DefaultValue : "godzilla" , Options : json .RawMessage ("[]" )},
282
- {Name : "is_debug_build" , Type : "bool" , Description : "This is third parameter" , Mutable : false , Options : json .RawMessage ("[]" )},
295
+ {Name : "is_debug_build" , Type : "bool" , Description : "This is third parameter" , Mutable : false , DefaultValue : "false" , Options : json .RawMessage ("[]" )},
296
+ {Name : "number_of_apples" , Type : "number" , Description : "This is fourth parameter" , Mutable : false , DefaultValue : "4" , Options : json .RawMessage ("[]" )},
297
+ {Name : "number_of_oranges" , Type : "number" , Description : "This is fifth parameter" , Mutable : false , DefaultValue : "6" , Options : json .RawMessage ("[]" )},
283
298
}
284
299
285
300
buildParameters := []codersdk.WorkspaceBuildParameter {
286
301
{Name : "project" , Value : "foobar-foobaz" },
287
- // "team" parameter is skipped, so default value is selected
288
302
{Name : "is_debug_build" , Value : "true" },
303
+ // Parameters "team", "number_of_apples", "number_of_oranges" are skipped, so default value is selected
289
304
}
290
305
291
306
ctx , cancel := context .WithCancel (context .Background ())
@@ -301,7 +316,24 @@ func TestWorkspaceBuildWithTags(t *testing.T) {
301
316
withWorkspaceTags (inactiveVersionID , workspaceTags ),
302
317
303
318
// Outputs
304
- expectProvisionerJob (func (_ database.InsertProvisionerJobParams ) {}),
319
+ expectProvisionerJob (func (job database.InsertProvisionerJobParams ) {
320
+ asrt .Len (job .Tags , 10 )
321
+
322
+ expected := database.StringMap {
323
+ "actually_no" : "false" ,
324
+ "cluster_tag" : "best_developers" ,
325
+ "fruits_tag" : "10" ,
326
+ "is_debug_build" : "in-debug-mode" ,
327
+ "project_tag" : "foobar-foobaz+12345" ,
328
+ "team_tag" : "godzilla" ,
329
+ "yes_or_no" : "true" ,
330
+
331
+ "scope" : "user" ,
332
+ "version" : "inactive" ,
333
+ "owner" : userID .String (),
334
+ }
335
+ asrt .Equal (job .Tags , expected )
336
+ }),
305
337
withInTx ,
306
338
expectBuild (func (_ database.InsertWorkspaceBuildParams ) {}),
307
339
expectBuildParameters (func (_ database.InsertWorkspaceBuildParametersParams ) {
0 commit comments