Skip to content

Commit

Permalink
test: add test case in worker
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Apr 10, 2024
1 parent 917ff96 commit e31f71f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
9 changes: 0 additions & 9 deletions tests/test_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,6 @@ describe('queues', function () {
});
});

describe('when 0.002 is used as blocktimeout', () => {
it('should not block forever', async () => {
const client = await queue.client;
await client.bzpopmin(`key`, 0.002);

expect(true).to.be.true;
});
});

describe('.removeDeprecatedPriorityKey', () => {
it('removes old priority key', async () => {
const client = await queue.client;
Expand Down
19 changes: 19 additions & 0 deletions tests/test_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,25 @@ describe('workers', function () {
await worker.close();
});

describe('when 0.002 is used as blocktimeout', () => {
it('should not block forever', async () => {
const worker = new Worker(queueName, async () => {}, {
connection,
prefix,
});
await worker.waitUntilReady();
const client = await worker.client;
if (isRedisVersionLowerThan(worker.redisVersion, '7.0.8')) {
await client.bzpopmin(`key`, 0.002);
} else {
await client.bzpopmin(`key`, 0.001);
}

expect(true).to.be.true;
await worker.close();
});
});

describe('when closing a worker', () => {
it('process a job that throws an exception after worker close', async () => {
const jobError = new Error('Job Failed');
Expand Down

0 comments on commit e31f71f

Please sign in to comment.