Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix redeclared test-http-* vars #4987

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions test/parallel/test-http-dns-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ if (common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
}

var expected_bad_requests = 0;
var actual_bad_requests = 0;

var host = '********';
host += host;
host += host;
Expand All @@ -25,23 +22,20 @@ function do_not_call() {
}

function test(mod) {
expected_bad_requests += 2;

// Bad host name should not throw an uncatchable exception.
// Ensure that there is time to attach an error listener.
var req = mod.get({host: host, port: 42}, do_not_call);
req.on('error', function(err) {
var req1 = mod.get({host: host, port: 42}, do_not_call);
req1.on('error', common.mustCall(function(err) {
assert.equal(err.code, 'ENOTFOUND');
actual_bad_requests++;
});
// http.get() called req.end() for us
}));
// http.get() called req1.end() for us

var req = mod.request({method: 'GET', host: host, port: 42}, do_not_call);
req.on('error', function(err) {
var req2 = mod.request({method: 'GET', host: host, port: 42}, do_not_call);
req2.on('error', common.mustCall(function(err) {
assert.equal(err.code, 'ENOTFOUND');
actual_bad_requests++;
});
req.end();
}));
req2.end();
}

if (common.hasCrypto) {
Expand All @@ -51,7 +45,3 @@ if (common.hasCrypto) {
}

test(http);

process.on('exit', function() {
assert.equal(actual_bad_requests, expected_bad_requests);
});
4 changes: 2 additions & 2 deletions test/parallel/test-http-full-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ function runAb(opts, callback) {
var m = /Document Length:\s*(\d+) bytes/mi.exec(stdout);
var documentLength = parseInt(m[1]);

var m = /Complete requests:\s*(\d+)/mi.exec(stdout);
m = /Complete requests:\s*(\d+)/mi.exec(stdout);
var completeRequests = parseInt(m[1]);

var m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout);
m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout);
var htmlTransfered = parseInt(m[1]);

assert.equal(bodyLength, documentLength);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function expectBody(expected) {
assert.equal(versionMajor, 1);
assert.equal(versionMinor, 0);

var headers = headers || parser.headers;
headers = headers || parser.headers;

assert.equal(headers.length, 2 * 256); // 256 key/value pairs
for (var i = 0; i < headers.length; i += 2) {
Expand Down