diff options
author | cjihrig <cjihrig@gmail.com> | 2016-07-15 15:43:24 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2016-07-18 17:14:16 -0400 |
commit | 04b4d15b396a7befea31dbfec89f69ff71dc71ca (patch) | |
tree | 7819010b9b687fb20328c04645e9ec64c25b9328 /test/parallel/test-https-client-checkServerIdentity.js | |
parent | 59741a9beeb0ccaac6fc3247605bf090d36ad50e (diff) | |
download | node-new-04b4d15b396a7befea31dbfec89f69ff71dc71ca.tar.gz |
test: use mustCall() for simple flow tracking
Many of the tests use variables to track when callback functions
are invoked or events are emitted. These variables are then
asserted on process exit. This commit replaces this pattern in
straightforward cases with common.mustCall(). This makes the
tests easier to reason about, leads to a net reduction in lines
of code, and uncovered a few bugs in tests. This commit also
replaces some callbacks that should never be called with
common.fail().
PR-URL: https://github.com/nodejs/node/pull/7753
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-https-client-checkServerIdentity.js')
-rw-r--r-- | test/parallel/test-https-client-checkServerIdentity.js | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/test/parallel/test-https-client-checkServerIdentity.js b/test/parallel/test-https-client-checkServerIdentity.js index 4b4bbc9d05..053a563005 100644 --- a/test/parallel/test-https-client-checkServerIdentity.js +++ b/test/parallel/test-https-client-checkServerIdentity.js @@ -16,14 +16,11 @@ var options = { cert: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-cert.pem')) }; -var reqCount = 0; - -var server = https.createServer(options, function(req, res) { - ++reqCount; +var server = https.createServer(options, common.mustCall(function(req, res) { res.writeHead(200); res.end(); req.resume(); -}).listen(0, function() { +})).listen(0, function() { authorized(); }); @@ -32,9 +29,7 @@ function authorized() { port: server.address().port, rejectUnauthorized: true, ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))] - }, function(res) { - assert(false); - }); + }, common.fail); req.on('error', function(err) { override(); }); @@ -60,7 +55,3 @@ function override() { }); req.end(); } - -process.on('exit', function() { - assert.equal(reqCount, 1); -}); |