From 510116ebe6edd2e325aa8b8690ed865a4d8966f7 Mon Sep 17 00:00:00 2001 From: Collins Abitekaniza Date: Thu, 7 Dec 2017 21:48:59 +0300 Subject: [PATCH] test: update http test to use common.mustCall PR-URL: https://github.com/nodejs/node/pull/17528 Reviewed-By: Anatoli Papirovski --- test/parallel/test-http-timeout-overflow.js | 22 +++++---------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/test/parallel/test-http-timeout-overflow.js b/test/parallel/test-http-timeout-overflow.js index dc93b3da7ae20d..e95405bc8b3554 100644 --- a/test/parallel/test-http-timeout-overflow.js +++ b/test/parallel/test-http-timeout-overflow.js @@ -20,19 +20,13 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); -const assert = require('assert'); - +const common = require('../common'); const http = require('http'); -let serverRequests = 0; -let clientRequests = 0; - -const server = http.createServer(function(req, res) { - serverRequests++; +const server = http.createServer(common.mustCall(function(req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('OK'); -}); +})); server.listen(0, function() { function callback() {} @@ -44,10 +38,9 @@ server.listen(0, function() { }, function(res) { req.clearTimeout(callback); - res.on('end', function() { - clientRequests++; + res.on('end', common.mustCall(function() { server.close(); - }); + })); res.resume(); }); @@ -56,8 +49,3 @@ server.listen(0, function() { req.setTimeout(0xffffffff, callback); req.end(); }); - -process.once('exit', function() { - assert.strictEqual(clientRequests, 1); - assert.strictEqual(serverRequests, 1); -});