@@ -613,6 +613,48 @@ func TestTemplatePush(t *testing.T) {
613
613
require .Equal (t , "second_variable" , templateVariables [1 ].Name )
614
614
require .Equal (t , "foobar" , templateVariables [1 ].Value )
615
615
})
616
+
617
+ t .Run ("CreateTemplate" , func (t * testing.T ) {
618
+ t .Parallel ()
619
+ client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerDaemon : true })
620
+ user := coderdtest .CreateFirstUser (t , client )
621
+ source := clitest .CreateTemplateVersionSource (t , & echo.Responses {
622
+ Parse : echo .ParseComplete ,
623
+ ProvisionApply : provisionCompleteWithAgent ,
624
+ })
625
+
626
+ const templateName = "my-template"
627
+ args := []string {
628
+ "templates" ,
629
+ "push" ,
630
+ templateName ,
631
+ "--directory" , source ,
632
+ "--test.provisioner" , string (database .ProvisionerTypeEcho ),
633
+ "--create" ,
634
+ }
635
+ inv , root := clitest .New (t , args ... )
636
+ clitest .SetupConfig (t , client , root )
637
+ pty := ptytest .New (t ).Attach (inv )
638
+
639
+ waiter := clitest .StartWithWaiter (t , inv )
640
+
641
+ matches := []struct {
642
+ match string
643
+ write string
644
+ }{
645
+ {match : "Upload" , write : "yes" },
646
+ }
647
+ for _ , m := range matches {
648
+ pty .ExpectMatch (m .match )
649
+ pty .WriteLine (m .write )
650
+ }
651
+
652
+ waiter .RequireSuccess ()
653
+
654
+ template , err := client .TemplateByName (context .Background (), user .OrganizationID , templateName )
655
+ require .NoError (t , err )
656
+ require .Equal (t , templateName , template .Name )
657
+ })
616
658
})
617
659
}
618
660
0 commit comments