MCPcopy Index your code
hub / github.com/coder/coder / TestWorkspaceWithOptionalRichParameters

Function TestWorkspaceWithOptionalRichParameters

coderd/workspaces_test.go:4530–4615  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4528}
4529
4530func TestWorkspaceWithOptionalRichParameters(t *testing.T) {
4531 t.Parallel()
4532
4533 const (
4534 firstParameterName = "first_parameter"
4535 firstParameterType = "string"
4536 firstParameterDescription = "This is _first_ *parameter*"
4537 firstParameterDefaultValue = "1"
4538
4539 secondParameterName = "second_parameter"
4540 secondParameterType = "number"
4541 secondParameterDescription = "_This_ is second *parameter*"
4542 secondParameterRequired = true
4543 secondParameterValue = "333"
4544 )
4545
4546 client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
4547 user := coderdtest.CreateFirstUser(t, client)
4548 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
4549 Parse: echo.ParseComplete,
4550 ProvisionGraph: []*proto.Response{
4551 {
4552 Type: &proto.Response_Graph{
4553 Graph: &proto.GraphComplete{
4554 Parameters: []*proto.RichParameter{
4555 {
4556 Name: firstParameterName,
4557 Type: firstParameterType,
4558 Description: firstParameterDescription,
4559 DefaultValue: firstParameterDefaultValue,
4560 },
4561 {
4562 Name: secondParameterName,
4563 Type: secondParameterType,
4564 Description: secondParameterDescription,
4565 Required: secondParameterRequired,
4566 },
4567 },
4568 },
4569 },
4570 },
4571 },
4572 ProvisionApply: []*proto.Response{{
4573 Type: &proto.Response_Apply{
4574 Apply: &proto.ApplyComplete{},
4575 },
4576 }},
4577 })
4578 coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
4579
4580 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
4581 defer cancel()
4582
4583 templateRichParameters, err := client.TemplateVersionRichParameters(ctx, version.ID)
4584 require.NoError(t, err)
4585 require.Len(t, templateRichParameters, 2)
4586 require.Equal(t, firstParameterName, templateRichParameters[0].Name)
4587 require.Equal(t, firstParameterType, templateRichParameters[0].Type)

Callers

nothing calls this directly

Calls 11

NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected