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

Function TestWorkspaceWithRichParameters

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

Source from the content-addressed store, hash-verified

4338}
4339
4340func TestWorkspaceWithRichParameters(t *testing.T) {
4341 t.Parallel()
4342
4343 const (
4344 firstParameterName = "first_parameter"
4345 firstParameterType = "string"
4346 firstParameterDescription = "This is _first_ *parameter*"
4347 firstParameterValue = "1"
4348
4349 secondParameterName = "second_parameter"
4350 secondParameterDisplayName = "Second Parameter"
4351 secondParameterType = "number"
4352 secondParameterDescription = "_This_ is second *parameter*"
4353 secondParameterValue = "2"
4354 secondParameterValidationMonotonic = codersdk.MonotonicOrderIncreasing
4355
4356 thirdParameterName = "third_parameter"
4357 thirdParameterType = "list(string)"
4358 thirdParameterFormType = proto.ParameterFormType_MULTISELECT
4359 thirdParameterDefault = `["red"]`
4360 thirdParameterOption = "red"
4361 )
4362
4363 client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
4364 user := coderdtest.CreateFirstUser(t, client)
4365 version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, &echo.Responses{
4366 Parse: echo.ParseComplete,
4367 ProvisionGraph: []*proto.Response{
4368 {
4369 Type: &proto.Response_Graph{
4370 Graph: &proto.GraphComplete{
4371 Parameters: []*proto.RichParameter{
4372 {
4373 Name: firstParameterName,
4374 Type: firstParameterType,
4375 Description: firstParameterDescription,
4376 FormType: proto.ParameterFormType_INPUT,
4377 },
4378 {
4379 Name: secondParameterName,
4380 DisplayName: secondParameterDisplayName,
4381 Type: secondParameterType,
4382 Description: secondParameterDescription,
4383 ValidationMin: ptr.Ref(int32(1)),
4384 ValidationMax: ptr.Ref(int32(3)),
4385 ValidationMonotonic: string(secondParameterValidationMonotonic),
4386 FormType: proto.ParameterFormType_INPUT,
4387 },
4388 {
4389 Name: thirdParameterName,
4390 Type: thirdParameterType,
4391 DefaultValue: thirdParameterDefault,
4392 Options: []*proto.RichParameterOption{
4393 {
4394 Name: thirdParameterOption,
4395 Value: thirdParameterOption,
4396 },
4397 },

Callers

nothing calls this directly

Calls 14

NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateTemplateVersionFunction · 0.92
RefFunction · 0.92
PlaintextFromMarkdownFunction · 0.92
ValidationMonotonicOrderTypeAlias · 0.92
CreateTemplateFunction · 0.92
CreateWorkspaceFunction · 0.92

Tested by

no test coverage detected