Skip to content

Commit

Permalink
test(job-scheduler): address PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Nov 28, 2024
1 parent 11988e5 commit 20fca7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
21 changes: 12 additions & 9 deletions tests/test_job_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ describe('Job Scheduler', function () {
});
});

describe('when repeatable job fails', async function () {
describe('when repeatable job fails', function () {
it('should continue repeating', async function () {
const repeatOpts = {
pattern: '0 * 1 * *',
Expand Down Expand Up @@ -1439,14 +1439,11 @@ describe('Job Scheduler', function () {
const delayedCount2 = await queue.getDelayedCount();
expect(delayedCount2).to.be.equal(1);

const configs = await repeat.getRepeatableJobs(0, -1, true);

expect(delayedCount).to.be.equal(1);
const jobSchedulers = await queue.getJobSchedulers();

const count = await queue.count();

expect(count).to.be.equal(1);
expect(configs).to.have.length(1);
expect(jobSchedulers).to.have.length(1);
await worker.close();
});

Expand Down Expand Up @@ -1498,11 +1495,17 @@ describe('Job Scheduler', function () {
every: 477,
};

let isFirstRun = true;

const worker = new Worker(
queueName,
async () => {
this.clock.tick(177);
throw new Error('failed');

if (isFirstRun) {
isFirstRun = false;
throw new Error('failed');
}
},
{
connection,
Expand Down Expand Up @@ -1585,10 +1588,10 @@ describe('Job Scheduler', function () {

// force remove the lock
const client = await queue.client;
const lockKey = `bull:${queueName}:${repeatableJob!.id}:lock`;
const lockKey = `${prefix}:${queueName}:${repeatableJob!.id}:lock`;
await client.del(lockKey);

const stalledCheckerKey = `bull:${queueName}:stalled-check`;
const stalledCheckerKey = `${prefix}:${queueName}:stalled-check`;
await client.del(stalledCheckerKey);

const scripts = (<any>worker!).scripts;
Expand Down
5 changes: 3 additions & 2 deletions tests/test_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ describe('queues', function () {

describe('use generics', function () {
it('should be able to use generics', async function () {
const queue = new Queue<{ foo: string; bar: number }>('test', {
const queue = new Queue<{ foo: string; bar: number }>(queueName, {
connection,
});
const job = await queue.add('{test}', { foo: 'bar', bar: 1 });

const job = await queue.add(queueName, { foo: 'bar', bar: 1 });
const job2 = await queue.getJob(job.id!);
expect(job2?.data.foo).to.be.eql('bar');
expect(job2?.data.bar).to.be.eql(1);
Expand Down

0 comments on commit 20fca7b

Please sign in to comment.