Skip to content

Commit

Permalink
fix(job): throw error if removeDependencyOnFailure and ignoreDependen…
Browse files Browse the repository at this point in the history
…cyOnFailure are used together (#2711)
  • Loading branch information
roggervalf authored Aug 16, 2024
1 parent 69d7ef3 commit 967632c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/classes/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,21 @@ export class Job<
);
}

if (
this.opts.removeDependencyOnFailure &&
this.opts.ignoreDependencyOnFailure
) {
throw new Error(
`RemoveDependencyOnFailure and ignoreDependencyOnFailure options can not be used together`,
);
}

if (this.opts.failParentOnFailure && this.opts.ignoreDependencyOnFailure) {
throw new Error(
`FailParentOnFailure and ignoreDependencyOnFailure options can not be used together`,
);
}

if (`${parseInt(this.id, 10)}` === this.id) {
throw new Error('Custom Ids cannot be integers');
}
Expand Down
26 changes: 26 additions & 0 deletions tests/test_job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,32 @@ describe('Job', function () {
});
});

describe('when removeDependencyOnFailure and ignoreDependencyOnFailure options are provided', () => {
it('throws an error', async () => {
const data = { foo: 'bar' };
const opts = {
removeDependencyOnFailure: true,
ignoreDependencyOnFailure: true,
};
await expect(Job.create(queue, 'test', data, opts)).to.be.rejectedWith(
'RemoveDependencyOnFailure and ignoreDependencyOnFailure options can not be used together',
);
});
});

describe('when failParentOnFailure and ignoreDependencyOnFailure options are provided', () => {
it('throws an error', async () => {
const data = { foo: 'bar' };
const opts = {
ignoreDependencyOnFailure: true,
failParentOnFailure: true,
};
await expect(Job.create(queue, 'test', data, opts)).to.be.rejectedWith(
'FailParentOnFailure and ignoreDependencyOnFailure options can not be used together',
);
});
});

describe('when priority option is provided as float', () => {
it('throws an error', async () => {
const data = { foo: 'bar' };
Expand Down

0 comments on commit 967632c

Please sign in to comment.