diff options
author | Dan.Williams <daniel@chat.za.net> | 2016-09-13 19:27:34 +0100 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2016-09-16 16:05:06 -0700 |
commit | a89c23f8ebb8d47e2f577d3594bfb465c1861d25 (patch) | |
tree | d950448eeaa87528c6d3070538e557c1492eb622 | |
parent | 7926886bf322ec9c69ec20afa26edfad17a47e08 (diff) | |
download | android-node-v8-a89c23f8ebb8d47e2f577d3594bfb465c1861d25.tar.gz android-node-v8-a89c23f8ebb8d47e2f577d3594bfb465c1861d25.tar.bz2 android-node-v8-a89c23f8ebb8d47e2f577d3594bfb465c1861d25.zip |
test: improve test-https-agent.js
On line 40: replace '==' with '==='
On line 52: replace 'assert.equal' with 'assert.strictEqual'
Added some comments.
Changed 'var' to 'const' where possible.
Replaced console.log(res.statusCode); with and assertion.
Rather than logging the https request status on every loop it will now
assert the https status is correct on every loop.
Changed the error listener to throw the error rather than log it.
PR-URL: https://github.com/nodejs/node/pull/8517
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
-rw-r--r-- | test/parallel/test-https-agent.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/test/parallel/test-https-agent.js b/test/parallel/test-https-agent.js index 2ad3bd8d01..221ed2bbd2 100644 --- a/test/parallel/test-https-agent.js +++ b/test/parallel/test-https-agent.js @@ -1,30 +1,31 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = https.Server(options, function(req, res) { +const server = https.Server(options, function(req, res) { res.writeHead(200); res.end('hello world\n'); }); var responses = 0; -var N = 4; -var M = 4; +const N = 4; +const M = 4; + server.listen(0, function() { for (var i = 0; i < N; i++) { @@ -36,11 +37,10 @@ server.listen(0, function() { rejectUnauthorized: false }, function(res) { res.resume(); - console.log(res.statusCode); - if (++responses == N * M) server.close(); + assert.strictEqual(res.statusCode, 200); + if (++responses === N * M) server.close(); }).on('error', function(e) { - console.log(e.message); - process.exit(1); + throw e; }); } }, i); @@ -49,5 +49,5 @@ server.listen(0, function() { process.on('exit', function() { - assert.equal(N * M, responses); + assert.strictEqual(N * M, responses); }); |