From fa16f76d8e7f0382378cf400554a78bd3134ef45 Mon Sep 17 00:00:00 2001 From: xtx1130 Date: Mon, 2 Sep 2019 14:39:12 +0800 Subject: [PATCH 1/2] test: add test cases for inspect --- package.json | 2 +- test/start.test.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 60946ff6..11241671 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/start.test.js b/test/start.test.js index 46cd95ef..4759bb20 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -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') + }) + }) +}) + test('boolean env are not overridden if no arguments are passed', t => { t.plan(1) From 084cfbdef45f0c1869fc832eafb4a2e1c651bb93 Mon Sep 17 00:00:00 2001 From: xtx1130 Date: Mon, 2 Sep 2019 15:16:30 +0800 Subject: [PATCH 2/2] ci: skip node v6 --- test/start.test.js | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/test/start.test.js b/test/start.test.js index 4759bb20..60f95d5b 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -483,48 +483,52 @@ 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') +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) + }) + const argv = ['--d', './examples/plugin.js'] - fastify.close(() => { - t.pass('server closed') + 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) + 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 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) + }) + const argv = ['--d', '--debug-port', port, './examples/plugin.js'] - fastify.close(() => { - t.pass('server closed') + 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)