Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf65dbba

Browse files
committed
fixup! fix: autostart/schedule: move to 5-valued cron string with weekly validation
1 parenta827d5c commitf65dbba

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

‎coderd/workspaces_test.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ func TestWorkspaceUpdateAutostart(t *testing.T) {
205205
},
206206
{
207207
name:"friday to monday",
208-
schedule:"CRON_TZ=Europe/Dublin 30 9 1-5",
208+
schedule:"CRON_TZ=Europe/Dublin 30 9* *1-5",
209209
expectedError:"",
210210
at:time.Date(2022,5,6,9,31,0,0,dublinLoc),
211211
expectedNext:time.Date(2022,5,9,9,30,0,0,dublinLoc),
212212
expectedInterval:71*time.Hour+59*time.Minute,
213213
},
214214
{
215215
name:"monday to tuesday",
216-
schedule:"CRON_TZ=Europe/Dublin 30 9 1-5",
216+
schedule:"CRON_TZ=Europe/Dublin 30 9* *1-5",
217217
expectedError:"",
218218
at:time.Date(2022,5,9,9,31,0,0,dublinLoc),
219219
expectedNext:time.Date(2022,5,10,9,30,0,0,dublinLoc),
@@ -222,7 +222,7 @@ func TestWorkspaceUpdateAutostart(t *testing.T) {
222222
{
223223
// DST in Ireland began on Mar 27 in 2022 at 0100. Forward 1 hour.
224224
name:"DST start",
225-
schedule:"CRON_TZ=Europe/Dublin 30 9 *",
225+
schedule:"CRON_TZ=Europe/Dublin 30 9 * * *",
226226
expectedError:"",
227227
at:time.Date(2022,3,26,9,31,0,0,dublinLoc),
228228
expectedNext:time.Date(2022,3,27,9,30,0,0,dublinLoc),
@@ -231,21 +231,26 @@ func TestWorkspaceUpdateAutostart(t *testing.T) {
231231
{
232232
// DST in Ireland ends on Oct 30 in 2022 at 0200. Back 1 hour.
233233
name:"DST end",
234-
schedule:"CRON_TZ=Europe/Dublin 30 9 *",
234+
schedule:"CRON_TZ=Europe/Dublin 30 9 * * *",
235235
expectedError:"",
236236
at:time.Date(2022,10,29,9,31,0,0,dublinLoc),
237237
expectedNext:time.Date(2022,10,30,9,30,0,0,dublinLoc),
238238
expectedInterval:24*time.Hour+59*time.Minute,
239239
},
240240
{
241241
name:"invalid location",
242-
schedule:"CRON_TZ=Imaginary/Place 30 9 1-5",
242+
schedule:"CRON_TZ=Imaginary/Place 30 9* *1-5",
243243
expectedError:"status code 500: invalid autostart schedule: parse schedule: provided bad location Imaginary/Place: unknown time zone Imaginary/Place",
244244
},
245245
{
246246
name:"invalid schedule",
247247
schedule:"asdf asdf asdf ",
248-
expectedError:`status code 500: invalid autostart schedule: parse schedule: failed to parse int from asdf: strconv.Atoi: parsing "asdf": invalid syntax`,
248+
expectedError:`status code 500: invalid autostart schedule: validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix`,
249+
},
250+
{
251+
name:"only 3 values",
252+
schedule:"CRON_TZ=Europe/Dublin 30 9 *",
253+
expectedError:`status code 500: invalid autostart schedule: validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix`,
249254
},
250255
}
251256

@@ -334,15 +339,15 @@ func TestWorkspaceUpdateAutostop(t *testing.T) {
334339
},
335340
{
336341
name:"friday to monday",
337-
schedule:"CRON_TZ=Europe/Dublin 30 17 1-5",
342+
schedule:"CRON_TZ=Europe/Dublin 30 17* *1-5",
338343
expectedError:"",
339344
at:time.Date(2022,5,6,17,31,0,0,dublinLoc),
340345
expectedNext:time.Date(2022,5,9,17,30,0,0,dublinLoc),
341346
expectedInterval:71*time.Hour+59*time.Minute,
342347
},
343348
{
344349
name:"monday to tuesday",
345-
schedule:"CRON_TZ=Europe/Dublin 30 17 1-5",
350+
schedule:"CRON_TZ=Europe/Dublin 30 17* *1-5",
346351
expectedError:"",
347352
at:time.Date(2022,5,9,17,31,0,0,dublinLoc),
348353
expectedNext:time.Date(2022,5,10,17,30,0,0,dublinLoc),
@@ -351,7 +356,7 @@ func TestWorkspaceUpdateAutostop(t *testing.T) {
351356
{
352357
// DST in Ireland began on Mar 27 in 2022 at 0100. Forward 1 hour.
353358
name:"DST start",
354-
schedule:"CRON_TZ=Europe/Dublin 30 17 *",
359+
schedule:"CRON_TZ=Europe/Dublin 30 17 * * *",
355360
expectedError:"",
356361
at:time.Date(2022,3,26,17,31,0,0,dublinLoc),
357362
expectedNext:time.Date(2022,3,27,17,30,0,0,dublinLoc),
@@ -360,21 +365,26 @@ func TestWorkspaceUpdateAutostop(t *testing.T) {
360365
{
361366
// DST in Ireland ends on Oct 30 in 2022 at 0200. Back 1 hour.
362367
name:"DST end",
363-
schedule:"CRON_TZ=Europe/Dublin 30 17 *",
368+
schedule:"CRON_TZ=Europe/Dublin 30 17 * * *",
364369
expectedError:"",
365370
at:time.Date(2022,10,29,17,31,0,0,dublinLoc),
366371
expectedNext:time.Date(2022,10,30,17,30,0,0,dublinLoc),
367372
expectedInterval:24*time.Hour+59*time.Minute,
368373
},
369374
{
370375
name:"invalid location",
371-
schedule:"CRON_TZ=Imaginary/Place 30 17 1-5",
376+
schedule:"CRON_TZ=Imaginary/Place 30 17* *1-5",
372377
expectedError:"status code 500: invalid autostop schedule: parse schedule: provided bad location Imaginary/Place: unknown time zone Imaginary/Place",
373378
},
374379
{
375380
name:"invalid schedule",
376381
schedule:"asdf asdf asdf ",
377-
expectedError:`status code 500: invalid autostop schedule: parse schedule: failed to parse int from asdf: strconv.Atoi: parsing "asdf": invalid syntax`,
382+
expectedError:`status code 500: invalid autostop schedule: validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix`,
383+
},
384+
{
385+
name:"only 3 values",
386+
schedule:"CRON_TZ=Europe/Dublin 30 9 *",
387+
expectedError:`status code 500: invalid autostop schedule: validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix`,
378388
},
379389
}
380390

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp