Skip to content

Commit

Permalink
test: ensure that high-frequency tasks do not block other tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Nov 26, 2020
1 parent b910bfa commit 674175e
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion test/planton/factories/createPlanton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,49 @@ test('unhandled scheduler errors trigger error event', async (t) => {
error,
taskName: 'foo',
});
});

test('high-frequency issues do not block other tasks', async (t) => {
const foo = sinon
.stub()
.callsFake(async () => {
await delay(10);

return [];
});

const bar = sinon
.stub()
.callsFake(async () => {
await delay(10);

return [];
});

const planton = createPlanton({
getActiveTaskInstructions: () => {
return [];
},
tasks: [
{
delay: () => {
return 5;
},
name: 'foo',
schedule: foo,
},
{
delay: () => {
return 50;
},
name: 'bar',
schedule: bar,
},
],
});

await delay(140);

t.true(true);
t.true(foo.callCount > 2);
t.true(bar.callCount > 2);
});

0 comments on commit 674175e

Please sign in to comment.