@@ -186,36 +186,54 @@ func TestWorkspaceBuildByName(t *testing.T) {
186
186
}
187
187
188
188
func TestWorkspaceUpdateAutostart (t * testing.T ) {
189
- // TODO(cian): CST -> CDT
190
- // TODO(cian): CDT -> CST
191
-
192
189
var dublinLoc = mustLocation (t , "Europe/Dublin" )
193
190
194
191
testCases := []struct {
195
- name string
196
- schedule string
197
- expectedError string
198
- at time.Time
199
- expectedNext time.Time
192
+ name string
193
+ schedule string
194
+ expectedError string
195
+ at time.Time
196
+ expectedNext time.Time
197
+ expectedInterval time.Duration
200
198
}{
201
199
{
202
200
name : "disable autostart" ,
203
201
schedule : "" ,
204
202
expectedError : "" ,
205
203
},
206
204
{
207
- name : "friday to monday" ,
208
- schedule : "CRON_TZ=Europe/Dublin 30 9 1-5" ,
209
- expectedError : "" ,
210
- at : time .Date (2022 , 5 , 6 , 9 , 31 , 0 , 0 , dublinLoc ),
211
- expectedNext : time .Date (2022 , 5 , 9 , 9 , 30 , 0 , 0 , dublinLoc ),
205
+ name : "friday to monday" ,
206
+ schedule : "CRON_TZ=Europe/Dublin 30 9 1-5" ,
207
+ expectedError : "" ,
208
+ at : time .Date (2022 , 5 , 6 , 9 , 31 , 0 , 0 , dublinLoc ),
209
+ expectedNext : time .Date (2022 , 5 , 9 , 9 , 30 , 0 , 0 , dublinLoc ),
210
+ expectedInterval : 71 * time .Hour + 59 * time .Minute ,
212
211
},
213
212
{
214
- name : "monday to tuesday" ,
215
- schedule : "CRON_TZ=Europe/Dublin 30 9 1-5" ,
216
- expectedError : "" ,
217
- at : time .Date (2022 , 5 , 9 , 9 , 31 , 0 , 0 , dublinLoc ),
218
- expectedNext : time .Date (2022 , 5 , 10 , 9 , 30 , 0 , 0 , dublinLoc ),
213
+ name : "monday to tuesday" ,
214
+ schedule : "CRON_TZ=Europe/Dublin 30 9 1-5" ,
215
+ expectedError : "" ,
216
+ at : time .Date (2022 , 5 , 9 , 9 , 31 , 0 , 0 , dublinLoc ),
217
+ expectedNext : time .Date (2022 , 5 , 10 , 9 , 30 , 0 , 0 , dublinLoc ),
218
+ expectedInterval : 23 * time .Hour + 59 * time .Minute ,
219
+ },
220
+ {
221
+ // DST in Ireland began on Mar 27 in 2022 at 0100. Forward 1 hour.
222
+ name : "DST start" ,
223
+ schedule : "CRON_TZ=Europe/Dublin 30 9 *" ,
224
+ expectedError : "" ,
225
+ at : time .Date (2022 , 3 , 26 , 9 , 31 , 0 , 0 , dublinLoc ),
226
+ expectedNext : time .Date (2022 , 3 , 27 , 9 , 30 , 0 , 0 , dublinLoc ),
227
+ expectedInterval : 22 * time .Hour + 59 * time .Minute ,
228
+ },
229
+ {
230
+ // DST in Ireland ends on Oct 30 in 2022 at 0200. Back 1 hour.
231
+ name : "DST end" ,
232
+ schedule : "CRON_TZ=Europe/Dublin 30 9 *" ,
233
+ expectedError : "" ,
234
+ at : time .Date (2022 , 10 , 29 , 9 , 31 , 0 , 0 , dublinLoc ),
235
+ expectedNext : time .Date (2022 , 10 , 30 , 9 , 30 , 0 , 0 , dublinLoc ),
236
+ expectedInterval : 24 * time .Hour + 59 * time .Minute ,
219
237
},
220
238
{
221
239
name : "invalid location" ,
@@ -270,6 +288,8 @@ func TestWorkspaceUpdateAutostart(t *testing.T) {
270
288
271
289
next := sched .Next (testCase .at )
272
290
require .Equal (t , testCase .expectedNext , next , "unexpected next scheduled autostart time" )
291
+ interval := next .Sub (testCase .at )
292
+ require .Equal (t , testCase .expectedInterval , interval , "unexpected interval" )
273
293
})
274
294
}
275
295
}
0 commit comments