Skip to content

Commit

Permalink
Test failure case
Browse files Browse the repository at this point in the history
  • Loading branch information
ersin-erdal committed May 6, 2022
1 parent 0cbbe16 commit e7938d9
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1517,9 +1517,7 @@ describe('TaskManagerRunner', () => {
`Skipping reschedule for task bar \"${id}\" due to the task expiring`
);
});
});

describe('run', () => {
test('Prints debug logs on task start and end', async () => {
const { runner, logger } = await readyToRunStageSetup({
definitions: {
Expand All @@ -1543,6 +1541,30 @@ describe('TaskManagerRunner', () => {
tags: ['task:end', 'foo', 'bar'],
});
});

test('Prints debug logs on task start and end even if it throws error', async () => {
const { runner, logger } = await readyToRunStageSetup({
definitions: {
bar: {
title: 'Bar!',
createTaskRunner: () => ({
async run() {
throw new Error();
},
}),
},
},
});
await runner.run();

expect(logger.debug).toHaveBeenCalledTimes(2);
expect(logger.debug).toHaveBeenNthCalledWith(1, 'Running task bar "foo"', {
tags: ['task:start', 'foo', 'bar'],
});
expect(logger.debug).toHaveBeenNthCalledWith(2, 'Task bar "foo" ended', {
tags: ['task:end', 'foo', 'bar'],
});
});
});

interface TestOpts {
Expand Down

0 comments on commit e7938d9

Please sign in to comment.