add job creation error

use it on creation error, update tests
This commit is contained in:
2016-07-11 16:03:59 -07:00
parent c758fb55a6
commit bfe8799b90
3 changed files with 5 additions and 5 deletions

View File

@@ -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',

View File

@@ -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);
});
}

View File

@@ -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();