Building Slack integration
This commit is contained in:
@@ -64,6 +64,40 @@ describe('queue', () => {
|
||||
expect(errors).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
/**
|
||||
* The whole point of classifying a failure as permanent: a revoked token or
|
||||
* a deleted channel cannot be fixed by trying again, and retrying it holds
|
||||
* up every job behind it.
|
||||
*/
|
||||
it('should abandon a job immediately when the error is marked permanent', async () => {
|
||||
configureQueue({ maxAttempts: 4 });
|
||||
let attempts = 0;
|
||||
|
||||
enqueue('permanently-failing', async () => {
|
||||
attempts += 1;
|
||||
throw Object.assign(new Error('token_revoked'), { permanent: true });
|
||||
});
|
||||
|
||||
await drain();
|
||||
|
||||
expect(attempts).toBe(1);
|
||||
expect(String(errors.mock.calls[0]?.[0])).toContain('abandoned as permanent');
|
||||
});
|
||||
|
||||
it('should still retry a job whose error carries a falsy permanent flag', async () => {
|
||||
configureQueue({ maxAttempts: 3 });
|
||||
let attempts = 0;
|
||||
|
||||
enqueue('transiently-failing', async () => {
|
||||
attempts += 1;
|
||||
throw Object.assign(new Error('ratelimited'), { permanent: false });
|
||||
});
|
||||
|
||||
await drain();
|
||||
|
||||
expect(attempts).toBe(3);
|
||||
});
|
||||
|
||||
it('should retry a failing job up to the configured cap and then give up', async () => {
|
||||
configureQueue({ maxAttempts: 4 });
|
||||
let attempts = 0;
|
||||
|
||||
Reference in New Issue
Block a user