@@ -251,6 +251,51 @@ func TestBuilder_ActiveVersion(t *testing.T) {
251
251
req .NoError (err )
252
252
}
253
253
254
+ func TestWorkspaceBuildWithTags (t * testing.T ) {
255
+ t .Parallel ()
256
+
257
+ req := require .New (t )
258
+
259
+ richParameters := []database.TemplateVersionParameter {
260
+ {Name : "cluster" , Description : "This is first parameter" , DefaultValue : "developers" , Mutable : false },
261
+ // Parameters can be mutable although it is discouraged as the workspace can be moved between provisioner nodes.
262
+ {Name : "project" , Description : "This is second parameter" , Mutable : true },
263
+ {Name : "is_debug_build" , Type : "bool" , Description : "This is third parameter" , Mutable : false },
264
+ }
265
+
266
+ buildParameters := []codersdk.WorkspaceBuildParameter {
267
+ {Name : "cluster" , Value : "developers" },
268
+ {Name : "project" , Value : "foobar-foobaz" },
269
+ {Name : "is_debug_build" , Value : "true" },
270
+ }
271
+
272
+ ctx , cancel := context .WithCancel (context .Background ())
273
+ defer cancel ()
274
+
275
+ mDB := expectDB (t ,
276
+ // Inputs
277
+ withTemplate ,
278
+ withInactiveVersion (richParameters ),
279
+ withLastBuildFound ,
280
+ withRichParameters (nil ),
281
+ withParameterSchemas (inactiveJobID , nil ),
282
+ withWorkspaceTags (inactiveVersionID , nil ),
283
+
284
+ // Outputs
285
+ expectProvisionerJob (func (_ database.InsertProvisionerJobParams ) {}),
286
+ withInTx ,
287
+ expectBuild (func (_ database.InsertWorkspaceBuildParams ) {}),
288
+ expectBuildParameters (func (_ database.InsertWorkspaceBuildParametersParams ) {
289
+ }),
290
+ withBuild ,
291
+ )
292
+
293
+ ws := database.Workspace {ID : workspaceID , TemplateID : templateID , OwnerID : userID }
294
+ uut := wsbuilder .New (ws , database .WorkspaceTransitionStart ).RichParameterValues (buildParameters )
295
+ _ , _ , err := uut .Build (ctx , mDB , nil , audit.WorkspaceBuildBaggage {})
296
+ req .NoError (err )
297
+ }
298
+
254
299
func TestWorkspaceBuildWithRichParameters (t * testing.T ) {
255
300
t .Parallel ()
256
301
@@ -402,11 +447,6 @@ func TestWorkspaceBuildWithRichParameters(t *testing.T) {
402
447
withRichParameters (nil ),
403
448
withParameterSchemas (inactiveJobID , schemas ),
404
449
withWorkspaceTags (inactiveVersionID , nil ),
405
-
406
- // Outputs
407
- expectProvisionerJob (func (job database.InsertProvisionerJobParams ) {}),
408
- withInTx ,
409
- expectBuild (func (bld database.InsertWorkspaceBuildParams ) {}),
410
450
)
411
451
412
452
ws := database.Workspace {ID : workspaceID , TemplateID : templateID , OwnerID : userID }
@@ -607,6 +647,7 @@ func TestWorkspaceBuildWithRichParameters(t *testing.T) {
607
647
withLastBuildFound ,
608
648
withRichParameters (initialBuildParameters ),
609
649
withParameterSchemas (activeJobID , nil ),
650
+ withWorkspaceTags (activeVersionID , nil ),
610
651
611
652
// Outputs
612
653
expectProvisionerJob (func (job database.InsertProvisionerJobParams ) {}),
0 commit comments