@@ -25,7 +25,17 @@ func TestCreate(t *testing.T) {
25
25
version := coderdtest .CreateTemplateVersion (t , client , user .OrganizationID , nil )
26
26
coderdtest .AwaitTemplateVersionJob (t , client , version .ID )
27
27
template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version .ID )
28
- cmd , root := clitest .New (t , "create" , "my-workspace" , "--template" , template .Name )
28
+ args := []string {
29
+ "create" ,
30
+ "my-workspace" ,
31
+ "--template" , template .Name ,
32
+ "--tz" , "US/Central" ,
33
+ "--autostart-minute" , "0" ,
34
+ "--autostart-hour" , "*/2" ,
35
+ "--autostart-day-of-week" , "MON-FRI" ,
36
+ "--ttl" , "8h" ,
37
+ }
38
+ cmd , root := clitest .New (t , args ... )
29
39
clitest .SetupConfig (t , client , root )
30
40
doneChan := make (chan struct {})
31
41
pty := ptytest .New (t )
@@ -48,6 +58,60 @@ func TestCreate(t *testing.T) {
48
58
<- doneChan
49
59
})
50
60
61
+ t .Run ("CreateErrInvalidTz" , func (t * testing.T ) {
62
+ t .Parallel ()
63
+ client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerD : true })
64
+ user := coderdtest .CreateFirstUser (t , client )
65
+ version := coderdtest .CreateTemplateVersion (t , client , user .OrganizationID , nil )
66
+ coderdtest .AwaitTemplateVersionJob (t , client , version .ID )
67
+ template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version .ID )
68
+ args := []string {
69
+ "create" ,
70
+ "my-workspace" ,
71
+ "--template" , template .Name ,
72
+ "--tz" , "invalid" ,
73
+ }
74
+ cmd , root := clitest .New (t , args ... )
75
+ clitest .SetupConfig (t , client , root )
76
+ doneChan := make (chan struct {})
77
+ pty := ptytest .New (t )
78
+ cmd .SetIn (pty .Input ())
79
+ cmd .SetOut (pty .Output ())
80
+ go func () {
81
+ defer close (doneChan )
82
+ err := cmd .Execute ()
83
+ require .EqualError (t , err , "Invalid workspace autostart timezone: unknown time zone invalid" )
84
+ }()
85
+ <- doneChan
86
+ })
87
+
88
+ t .Run ("CreateErrInvalidTTL" , func (t * testing.T ) {
89
+ t .Parallel ()
90
+ client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerD : true })
91
+ user := coderdtest .CreateFirstUser (t , client )
92
+ version := coderdtest .CreateTemplateVersion (t , client , user .OrganizationID , nil )
93
+ coderdtest .AwaitTemplateVersionJob (t , client , version .ID )
94
+ template := coderdtest .CreateTemplate (t , client , user .OrganizationID , version .ID )
95
+ args := []string {
96
+ "create" ,
97
+ "my-workspace" ,
98
+ "--template" , template .Name ,
99
+ "--ttl" , "0s" ,
100
+ }
101
+ cmd , root := clitest .New (t , args ... )
102
+ clitest .SetupConfig (t , client , root )
103
+ doneChan := make (chan struct {})
104
+ pty := ptytest .New (t )
105
+ cmd .SetIn (pty .Input ())
106
+ cmd .SetOut (pty .Output ())
107
+ go func () {
108
+ defer close (doneChan )
109
+ err := cmd .Execute ()
110
+ require .EqualError (t , err , "TTL must be at least 1 minute" )
111
+ }()
112
+ <- doneChan
113
+ })
114
+
51
115
t .Run ("CreateFromListWithSkip" , func (t * testing.T ) {
52
116
t .Parallel ()
53
117
client := coderdtest .New (t , & coderdtest.Options {IncludeProvisionerD : true })
0 commit comments