Skip to content

Commit

Permalink
fixing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
podviaznikov committed Sep 28, 2016
1 parent b2f33f2 commit 58e56e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,10 @@ class RabbitMQ {
timestamp: Date.now(),
headers: {}
}
const ns = getNamespace('ponos')
jobMeta.headers.previousEvent = ns && ns.get('previousEvent')
// add tid to message if one does not exist
if (!content.tid) {
const ns = getNamespace('ponos')
if (ns) {
jobMeta.headers.previousEvent = ns.get('previousEvent')
}
const tid = ns && ns.get('tid')
content.tid = tid || uuid()
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/rabbitmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,12 @@ describe('rabbitmq', () => {
})
})
})

it('should not set previousEvent if namespace does not exist', () => {
const payload = RabbitMQ.buildPayload({})
assert.isUndefined(payload.jobMeta.headers.previousEvent)
})

describe('stringify error', function () {
beforeEach(() => {
sinon.stub(JSON, 'stringify').throws(new Error('custom json error'))
Expand Down

0 comments on commit 58e56e1

Please sign in to comment.