Skip to content

Commit

Permalink
test: use common.mustCall in test-https-strict
Browse files Browse the repository at this point in the history
PR-URL: #12668
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
weewey authored and jasnell committed Apr 28, 2017
1 parent 972bfe1 commit f11d4a1
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions test/parallel/test-https-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ server2.listen(0, listening());
server3.listen(0, listening());

const responseErrors = {};
let expectResponseCount = 0;
let responseCount = 0;
let pending = 0;


Expand Down Expand Up @@ -147,17 +145,14 @@ function makeReq(path, port, error, host, ca) {
options.headers = { host: host };
}
const req = https.get(options);
expectResponseCount++;
const server = port === server1.address().port ? server1 :
port === server2.address().port ? server2 :
port === server3.address().port ? server3 :
null;

if (!server) throw new Error('invalid port: ' + port);
server.expectCount++;

req.on('response', (res) => {
responseCount++;
req.on('response', common.mustCall((res) => {
assert.strictEqual(res.connection.authorizationError, error);
responseErrors[path] = res.connection.authorizationError;
pending--;
Expand All @@ -167,7 +162,7 @@ function makeReq(path, port, error, host, ca) {
server3.close();
}
res.resume();
});
}));
}

function allListening() {
Expand Down Expand Up @@ -220,5 +215,4 @@ process.on('exit', () => {
assert.strictEqual(server1.requests.length, server1.expectCount);
assert.strictEqual(server2.requests.length, server2.expectCount);
assert.strictEqual(server3.requests.length, server3.expectCount);
assert.strictEqual(responseCount, expectResponseCount);
});

0 comments on commit f11d4a1

Please sign in to comment.