Retry outbound reactions for up to a day

This commit is contained in:
Evan Hahn 2021-10-29 18:19:44 -05:00 committed by GitHub
parent 4a6b7968c1
commit 8670a4d864
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1444 additions and 473 deletions

View file

@ -0,0 +1,44 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { InMemoryQueues } from '../../../jobs/helpers/InMemoryQueues';
describe('InMemoryQueues', () => {
describe('get', () => {
it('returns a new PQueue for each key', () => {
const queues = new InMemoryQueues();
assert.strictEqual(queues.get('a'), queues.get('a'));
assert.notStrictEqual(queues.get('a'), queues.get('b'));
assert.notStrictEqual(queues.get('b'), queues.get('c'));
});
it('returns a queue that only executes one thing at a time', () => {
const queue = new InMemoryQueues().get('foo');
assert.strictEqual(queue.concurrency, 1);
});
it('cleans up the queues when all tasks have run', async () => {
const queues = new InMemoryQueues();
const originalQueue = queues.get('foo');
originalQueue.pause();
const tasksPromise = originalQueue.addAll([
async () => {
assert.strictEqual(queues.get('foo'), originalQueue);
},
async () => {
assert.strictEqual(queues.get('foo'), originalQueue);
},
]);
originalQueue.start();
await tasksPromise;
assert.notStrictEqual(queues.get('foo'), originalQueue);
});
});
});