Skip to content

Commit

Permalink
test: add test cases for inspect (#203)
Browse files Browse the repository at this point in the history
* test: add test cases for inspect

* ci: skip node v6
  • Loading branch information
xtx1130 authored and mcollina committed Sep 2, 2019
1 parent 22e4c1e commit 3befd11
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -63,7 +63,7 @@
"minimatch": "^3.0.4",
"mkdirp": "^0.5.1",
"pre-commit": "^1.2.2",
"proxyquire": "^2.0.1",
"proxyquire": "^2.1.3",
"rimraf": "^3.0.0",
"simple-get": "^3.0.3",
"sinon": "^7.3.2",
Expand Down
47 changes: 47 additions & 0 deletions test/start.test.js
Expand Up @@ -483,6 +483,53 @@ test('crash on unhandled rejection', t => {
})
})

if (!process.version.match(/v[0-6]\..*/g)) {
test('should start the server with inspect options and the defalut port is 9320', t => {
t.plan(4)

const start = proxyquire('../start', {
inspector: {
open (p) {
t.strictEqual(p, 9320)
t.pass('inspect open called')
}
}
})
const argv = ['--d', './examples/plugin.js']

start.start(argv, (err, fastify) => {
t.error(err)

fastify.close(() => {
t.pass('server closed')
})
})
})

test('should start the server with inspect options and use the exactly port', t => {
t.plan(4)

const port = getPort()
const start = proxyquire('../start', {
inspector: {
open (p) {
t.strictEqual(p, Number(port))
t.pass('inspect open called')
}
}
})
const argv = ['--d', '--debug-port', port, './examples/plugin.js']

start.start(argv, (err, fastify) => {
t.error(err)

fastify.close(() => {
t.pass('server closed')
})
})
})
}

test('boolean env are not overridden if no arguments are passed', t => {
t.plan(1)

Expand Down

0 comments on commit 3befd11

Please sign in to comment.