Skip to content

Commit

Permalink
test: add some coverage (#2662)
Browse files Browse the repository at this point in the history
* test: cover passing backlog as second last arg to listen

* refactor: remove unnecessary elseif
  • Loading branch information
salmanm committed Nov 9, 2020
1 parent 1175777 commit c16f74b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ const onBadUrlContext = {
}

function defaultErrorHandler (error, request, reply) {
if (reply.statusCode >= 500) {
reply.log.error(
{ req: request, res: reply, err: error },
error && error.message
)
} else if (reply.statusCode >= 400) {
if (reply.statusCode < 500) {
reply.log.info(
{ res: reply, err: error },
error && error.message
)
} else {
reply.log.error(
{ req: request, res: reply, err: error },
error && error.message
)
}
reply.send(error)
}
Expand Down
12 changes: 12 additions & 0 deletions test/listen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ test('listen accepts options and a callback', t => {
})
})

test('listen accepts options, backlog and a callback', t => {
t.plan(1)
const fastify = Fastify()
t.tearDown(fastify.close.bind(fastify))
fastify.listen({
port: 0,
host: 'localhost'
}, 511, (err) => {
t.error(err)
})
})

test('listen accepts a port, address and a callback with (err, address)', t => {
t.plan(2)
const fastify = Fastify()
Expand Down

0 comments on commit c16f74b

Please sign in to comment.