summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-upgrade-client.js
diff options
context:
space:
mode:
authorMithun Sasidharan <mithunsasidharan89@gmail.com>2017-11-27 12:44:12 +0530
committerJon Moss <me@jonathanmoss.me>2017-12-03 14:26:34 -0500
commiteb19c6b39f5494eef501494b701aeb592f59a2aa (patch)
tree0a329efeec4b6c7e15b8519c689e5fc6f36d39f5 /test/parallel/test-http-upgrade-client.js
parent2afd4e779c8e562dea83a58b46a2b348c07df59b (diff)
downloadandroid-node-v8-eb19c6b39f5494eef501494b701aeb592f59a2aa.tar.gz
android-node-v8-eb19c6b39f5494eef501494b701aeb592f59a2aa.tar.bz2
android-node-v8-eb19c6b39f5494eef501494b701aeb592f59a2aa.zip
test: update test-http-upgrade-client to use countdown
PR-URL: https://github.com/nodejs/node/pull/17339 Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'test/parallel/test-http-upgrade-client.js')
-rw-r--r--test/parallel/test-http-upgrade-client.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js
index 3c56e5959f..c637324a53 100644
--- a/test/parallel/test-http-upgrade-client.js
+++ b/test/parallel/test-http-upgrade-client.js
@@ -29,6 +29,7 @@ const assert = require('assert');
const http = require('http');
const net = require('net');
+const Countdown = require('../common/countdown');
// Create a TCP server
const srv = net.createServer(function(c) {
@@ -60,7 +61,8 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
['Origin', 'http://www.websocket.org']
]
];
- let left = headers.length;
+ const countdown = new Countdown(headers.length, () => srv.close());
+
headers.forEach(function(h) {
const req = http.get({
port: port,
@@ -87,8 +89,7 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() {
assert.deepStrictEqual(expectedHeaders, res.headers);
socket.end();
- if (--left === 0)
- srv.close();
+ countdown.dec();
}));
req.on('close', common.mustCall(function() {
assert.strictEqual(sawUpgrade, true);