put job info under job property on success emitter

This commit is contained in:
2016-07-11 10:27:08 -07:00
parent 3b135bbd09
commit 27390fef44
2 changed files with 9 additions and 5 deletions

View File

@@ -183,10 +183,10 @@ export default class Job extends events.EventEmitter {
// job execution was successful
this.debug(`Completed job ${job._id}`);
const emitJob = formatJobObject(job);
const completedTime = moment().toISOString();
const docOutput = this._formatOutput(output);
const emitJob = { job: formatJobObject(job) };
const doc = {
status: constants.JOB_STATUS_COMPLETED,
completed_at: completedTime,

View File

@@ -601,13 +601,17 @@ describe('Worker class', function () {
worker.once(constants.EVENT_WORKER_COMPLETE, (workerJob) => {
try {
expect(workerJob).to.have.property('id');
expect(workerJob).to.have.property('index');
expect(workerJob).to.have.property('type');
expect(workerJob).to.not.have.property('_source');
expect(workerJob).to.have.property('job');
expect(workerJob.job).to.have.property('id');
expect(workerJob.job).to.have.property('index');
expect(workerJob.job).to.have.property('type');
expect(workerJob).to.have.property('output');
expect(workerJob.output).to.have.property('content');
expect(workerJob.output).to.have.property('content_type');
expect(workerJob).to.not.have.property('_source');
done();
} catch (e) {
done(e);