Permalink
Browse files

test: update test-http-upgrade-client to use countdown

PR-URL: #17339
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
  • Loading branch information...
mithunsasidharan authored and gibfahn committed Nov 27, 2017
1 parent 8f997c0 commit 660e6dea8993d0a10748dc4e8aa61465aa74d631
Showing with 4 additions and 3 deletions.
  1. +4 −3 test/parallel/test-http-upgrade-client.js
@@ -8,6 +8,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) {
@@ -39,7 +40,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,
@@ -66,8 +68,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);

0 comments on commit 660e6de

Please sign in to comment.