From 31c5db6c03bcfb7371f02563f7c490476ee20e6c Mon Sep 17 00:00:00 2001 From: Bamieh Date: Tue, 12 Dec 2017 22:44:08 +0200 Subject: [PATCH] test: update test-http-content-length to use countdown PR-URL: https://github.com/nodejs/node/pull/17201 Reviewed-By: James M Snell Reviewed-By: Evan Lucas Reviewed-By: Gireesh Punathil Reviewed-By: Jon Moss --- test/parallel/test-http-content-length.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http-content-length.js b/test/parallel/test-http-content-length.js index 3d6882d92f04b3..e6ba3719f95ba6 100644 --- a/test/parallel/test-http-content-length.js +++ b/test/parallel/test-http-content-length.js @@ -2,6 +2,7 @@ require('../common'); const assert = require('assert'); const http = require('http'); +const Countdown = require('../common/countdown'); const expectedHeadersMultipleWrites = { 'connection': 'close', @@ -18,8 +19,8 @@ const expectedHeadersEndNoData = { 'content-length': '0', }; -let receivedRequests = 0; -const totalRequests = 3; + +const countdown = new Countdown(3, () => server.close()); const server = http.createServer(function(req, res) { res.removeHeader('Date'); @@ -42,8 +43,7 @@ const server = http.createServer(function(req, res) { throw new Error('Unreachable'); } - receivedRequests++; - if (totalRequests === receivedRequests) server.close(); + countdown.dec(); }); server.listen(0, function() {