Skip to content

Commit

Permalink
fix(test): Use correct expected result for error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
emelski committed May 19, 2022
1 parent f00421a commit ea88daf
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions test/logger-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,13 @@ test('error event when _serializeBuffer throws', (t) => {
.reply(200, 'Ingester response')

logger.on('error', (err) => {
t.same(
t.match(
err
, {
meta: {
actual: 'bad serialization'
, firstLine: 'This is the line'
, lastLine: null
, url: logger.url
}
, name: 'Error'
, message: 'Error serializing buffer'
Expand All @@ -753,30 +752,39 @@ test('error event when _serializeBuffer throws, verboseEvents', (t) => {
, createOptions({verboseEvents: true})
)
const line = 'This is the line'
t.plan(1)
t.plan(2)
nock(logger.url)
.post('/', (body) => {
return true
})
.query(() => { return true })
.reply(200, 'Ingester response')

const timestamp = Date.now()
logger.on('error', (err) => {
t.same(
t.type(err, Error, 'Error type is emitted')
t.match(
err
, {
meta: {
message: 'Error serializing buffer'
, meta: {
actual: 'bad serialization'
, firstLine: 'This is the line'
, lastLine: null
, url: logger.url
, buffer: ['This is the line']
, buffer: [
{
timestamp
, line: 'This is the line'
, level: 'INFO'
, app: 'testing.log'
, env: undefined
, meta: '{}'
}
]
}
, name: 'Error'
, message: 'Error serializing buffer'
}
, 'error emitted for serialization failure'
)
})
logger.log(line)
logger.log(line, {timestamp})
})

0 comments on commit ea88daf

Please sign in to comment.