@@ -453,6 +453,8 @@ func TestCreateValidateRichParameters(t *testing.T) {
453
453
stringParameterName = "string_parameter"
454
454
stringParameterValue = "abc"
455
455
456
+ listOfStringsParameterName = "list_of_strings_parameter"
457
+
456
458
numberParameterName = "number_parameter"
457
459
numberParameterValue = "7"
458
460
@@ -468,6 +470,10 @@ func TestCreateValidateRichParameters(t *testing.T) {
468
470
{Name : stringParameterName , Type : "string" , Mutable : true , ValidationRegex : "^[a-z]+$" , ValidationError : "this is error" },
469
471
}
470
472
473
+ listOfStringsRichParameters := []* proto.RichParameter {
474
+ {Name : listOfStringsParameterName , Type : "list(string)" , Mutable : true , DefaultValue : `["aaa","bbb","ccc"]` },
475
+ }
476
+
471
477
boolRichParameters := []* proto.RichParameter {
472
478
{Name : boolParameterName , Type : "bool" , Mutable : true },
473
479
}
@@ -607,6 +613,43 @@ func TestCreateValidateRichParameters(t *testing.T) {
607
613
}
608
614
<- doneChan
609
615
})
616
+
617
+ t .Run ("ValidateListOfStrings" , func (t * testing.T ) {
618
+ t .Parallel ()
619
+
620
+ client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerDaemon : true })
621
+ user := coderdtest .CreateFirstUser (t , client )
622
+ version := coderdtest .CreateTemplateVersion (t , client , user .OrganizationID , prepareEchoResponses (listOfStringsRichParameters ))
623
+ coderdtest .AwaitTemplateVersionJob (t , client , version .ID )
624
+ template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version .ID )
625
+
626
+ cmd , root := clitest .New (t , "create" , "my-workspace" , "--template" , template .Name )
627
+ clitest .SetupConfig (t , client , root )
628
+ doneChan := make (chan struct {})
629
+ pty := ptytest .New (t )
630
+ cmd .SetIn (pty .Input ())
631
+ cmd .SetOut (pty .Output ())
632
+ go func () {
633
+ defer close (doneChan )
634
+ err := cmd .Execute ()
635
+ assert .NoError (t , err )
636
+ }()
637
+
638
+ matches := []string {
639
+ listOfStringsParameterName , "" ,
640
+ "aaa, bbb, ccc" , "" ,
641
+ "Confirm create?" , "yes" ,
642
+ }
643
+ for i := 0 ; i < len (matches ); i += 2 {
644
+ match := matches [i ]
645
+ value := matches [i + 1 ]
646
+ pty .ExpectMatch (match )
647
+ if value != "" {
648
+ pty .WriteLine (value )
649
+ }
650
+ }
651
+ <- doneChan
652
+ })
610
653
}
611
654
612
655
func TestCreateWithGitAuth (t * testing.T ) {
0 commit comments