Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
garysassano committed Mar 16, 2024
1 parent 4545e9f commit 997ee7f
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions examples/tests/sdk_tests/schedule/on_tick.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@ bring util;
bring expect;

// Trigger schedule every minute
// let from_cron = new cloud.Schedule( cron: "* * * * *" ) as "from_cron";
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();
});

test "onTick()" {
// let c1Value = c1.peek();
// std.Test is used setting the timeout property
new std.Test(inflight () => {
let c1Value = c1.peek();
let c2Value = c2.peek();


// wait at least one minute
util.sleep(1.5m);

// Check that both counters have been incremented
// expect.equal(c1Value, 0);
// assert(c1.peek() >= c1Value + 1);
expect.equal(c1Value, 0);
assert(c1.peek() >= c1Value + 1);
expect.equal(c2Value, 0);
assert(c2.peek() >= c2Value + 1);
}
}, timeout: 2m) as "onTick()";

0 comments on commit 997ee7f

Please sign in to comment.