(t *testing.T)
| 416 | } |
| 417 | |
| 418 | func TestWorkspaceBuildWithRichParameters(t *testing.T) { |
| 419 | t.Parallel() |
| 420 | |
| 421 | const ( |
| 422 | firstParameterName = "first_parameter" |
| 423 | firstParameterDescription = "This is first parameter" |
| 424 | firstParameterValue = "1" |
| 425 | |
| 426 | secondParameterName = "second_parameter" |
| 427 | secondParameterDescription = "This is second parameter" |
| 428 | secondParameterValue = "2" |
| 429 | |
| 430 | immutableParameterName = "immutable_parameter" |
| 431 | immutableParameterDescription = "This is immutable parameter" |
| 432 | immutableParameterValue = "3" |
| 433 | ) |
| 434 | |
| 435 | initialBuildParameters := []database.WorkspaceBuildParameter{ |
| 436 | {Name: firstParameterName, Value: firstParameterValue}, |
| 437 | {Name: secondParameterName, Value: secondParameterValue}, |
| 438 | {Name: immutableParameterName, Value: immutableParameterValue}, |
| 439 | } |
| 440 | |
| 441 | richParameters := []database.TemplateVersionParameter{ |
| 442 | {Name: firstParameterName, Description: firstParameterDescription, Mutable: true, Options: json.RawMessage("[]")}, |
| 443 | {Name: secondParameterName, Description: secondParameterDescription, Mutable: true, Options: json.RawMessage("[]")}, |
| 444 | {Name: immutableParameterName, Description: immutableParameterDescription, Mutable: false, Options: json.RawMessage("[]")}, |
| 445 | } |
| 446 | |
| 447 | t.Run("UpdateParameterValues", func(t *testing.T) { |
| 448 | t.Parallel() |
| 449 | |
| 450 | req := require.New(t) |
| 451 | asrt := assert.New(t) |
| 452 | |
| 453 | ctx, cancel := context.WithCancel(context.Background()) |
| 454 | defer cancel() |
| 455 | |
| 456 | const updatedParameterValue = "3" |
| 457 | nextBuildParameters := []codersdk.WorkspaceBuildParameter{ |
| 458 | {Name: firstParameterName, Value: firstParameterValue}, |
| 459 | {Name: secondParameterName, Value: updatedParameterValue}, |
| 460 | } |
| 461 | expectedParams := map[string]string{ |
| 462 | firstParameterName: firstParameterValue, |
| 463 | secondParameterName: updatedParameterValue, |
| 464 | immutableParameterName: immutableParameterValue, |
| 465 | } |
| 466 | |
| 467 | mDB := expectDB(t, |
| 468 | // Inputs |
| 469 | withTemplate, |
| 470 | withInactiveVersion(richParameters), |
| 471 | withLastBuildFound, |
| 472 | withLastBuildState, |
| 473 | withTemplateVersionVariables(inactiveVersionID, nil), |
| 474 | withRichParameters(initialBuildParameters), |
| 475 | withParameterSchemas(inactiveJobID, nil), |
nothing calls this directly
no test coverage detected