add job creation error
use it on creation error, update tests
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
export default {
|
||||
EVENT_QUEUE_ERROR: 'error',
|
||||
EVENT_JOB_CREATED: 'job:created',
|
||||
EVENT_JOB_ERROR: 'job:error',
|
||||
EVENT_WORKER_ERROR: 'worker:error',
|
||||
EVENT_JOB_CREATED: 'job:created',
|
||||
EVENT_JOB_CREATE_ERROR: 'job:creation error',
|
||||
EVENT_WORKER_COMPLETE: 'worker:job complete',
|
||||
EVENT_WORKER_JOB_CLAIM_ERROR: 'worker:claim job error',
|
||||
EVENT_WORKER_JOB_SEARCH_ERROR: 'worker:pending jobs error',
|
||||
|
||||
@@ -62,7 +62,7 @@ export default class Job extends events.EventEmitter {
|
||||
})
|
||||
.catch((err) => {
|
||||
this.debug('Job creation failed', err);
|
||||
this.emit(contstants.EVENT_JOB_ERROR, err);
|
||||
this.emit(contstants.EVENT_JOB_CREATE_ERROR, err);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('Job Class', function () {
|
||||
createIndexMock.returns(Promise.reject(new Error(errMsg)));
|
||||
const job = new Job(mockQueue, index, type, payload);
|
||||
|
||||
job.once(contstants.EVENT_JOB_ERROR, (err) => {
|
||||
job.once(contstants.EVENT_JOB_CREATE_ERROR, (err) => {
|
||||
try {
|
||||
expect(err.message).to.equal(errMsg);
|
||||
done();
|
||||
@@ -150,7 +150,7 @@ describe('Job Class', function () {
|
||||
sinon.stub(client, 'index', () => Promise.reject(new Error(errMsg)));
|
||||
const job = new Job(mockQueue, index, type, payload);
|
||||
|
||||
job.once(contstants.EVENT_JOB_ERROR, (err) => {
|
||||
job.once(contstants.EVENT_JOB_CREATE_ERROR, (err) => {
|
||||
try {
|
||||
expect(err.message).to.equal(errMsg);
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user