-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aae7e30
commit 99d9e0a
Showing
2 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
bring cloud; | ||
bring util; | ||
bring expect; | ||
|
||
// every minute | ||
let from_cron = new cloud.Schedule( cron: "* * * * ?" ) as "from_cron"; | ||
// Trigger schedule every minute | ||
// let from_cron = new cloud.Schedule( cron: "* * * * *" ) as "from_cron"; | ||
let from_rate = new cloud.Schedule( rate: 1m ) as "from_rate"; | ||
let c1 = new cloud.Counter() as "c1"; | ||
// let c1 = new cloud.Counter() as "c1"; | ||
let c2 = new cloud.Counter() as "c2"; | ||
|
||
from_cron.onTick(inflight () => { | ||
c1.inc(); | ||
}); | ||
// from_cron.onTick(inflight () => { | ||
// c1.inc(); | ||
// }); | ||
|
||
from_rate.onTick(inflight () => { | ||
c2.inc(); | ||
}); | ||
|
||
// std.Test is used setting the timeout property | ||
new std.Test(inflight () => { | ||
let c1Value = c1.peek(); | ||
test "onTick()" { | ||
// let c1Value = c1.peek(); | ||
let c2Value = c2.peek(); | ||
|
||
|
||
// wait at least one minute | ||
util.sleep(1.1m); | ||
util.sleep(1.5m); | ||
|
||
// check that both counters have been incremented | ||
assert(c1.peek() >= c1Value + 1); | ||
// Check that both counters have been incremented | ||
// expect.equal(c1Value, 0); | ||
// assert(c1.peek() >= c1Value + 1); | ||
expect.equal(c2Value, 0); | ||
assert(c2.peek() >= c2Value + 1); | ||
}, timeout: 2m) as "on tick is called both for rate and cron schedules"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters