Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test cases for inspect #203

Merged
merged 2 commits into from
Sep 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
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
43 changes: 43 additions & 0 deletions test/start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,49 @@ test('crash on unhandled rejection', t => {
})
})

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')
})
})
})
xtx1130 marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down