-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
test.schedule.ts
47 lines (42 loc) · 1.32 KB
/
test.schedule.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Duration } from '@aws-cdk/core';
import { Test } from 'nodeunit';
import * as events from '../lib';
export = {
'cron expressions day and dow are mutex: given weekday'(test: Test) {
// Run every 10 minutes Monday through Friday
test.equal('cron(0/10 * ? * MON-FRI *)', events.Schedule.cron({
minute: '0/10',
weekDay: 'MON-FRI',
}).expressionString);
test.done();
},
'cron expressions day and dow are mutex: given month day'(test: Test) {
// Run at 8:00 am (UTC) every 1st day of the month
test.equal('cron(0 8 1 * ? *)', events.Schedule.cron({
minute: '0',
hour: '8',
day: '1',
}).expressionString);
test.done();
},
'cron expressions day and dow are mutex: given neither'(test: Test) {
// Run at 10:00 am (UTC) every day
test.equal('cron(0 10 * * ? *)', events.Schedule.cron({
minute: '0',
hour: '10',
}).expressionString);
test.done();
},
'rate must be whole number of minutes'(test: Test) {
test.throws(() => {
events.Schedule.rate(Duration.seconds(12345));
}, /'12345 seconds' cannot be converted into a whole number of minutes/);
test.done();
},
'rate cannot be 0'(test: Test) {
test.throws(() => {
events.Schedule.rate(Duration.days(0));
}, /Duration cannot be 0/);
test.done();
},
};