From 9dd5b3e01ba417d27af1932e8f35a118d8dbb584 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 30 Jan 2016 20:43:11 -0800 Subject: [PATCH] test: fix redeclared test-http-* vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/4987 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell Reviewed-By: Roman Klauke --- test/parallel/test-http-dns-error.js | 26 ++++++++---------------- test/parallel/test-http-full-response.js | 4 ++-- test/parallel/test-http-parser.js | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/test/parallel/test-http-dns-error.js b/test/parallel/test-http-dns-error.js index 55195e45b715ff..ad360f5b4db4c4 100644 --- a/test/parallel/test-http-dns-error.js +++ b/test/parallel/test-http-dns-error.js @@ -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; @@ -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) { @@ -51,7 +45,3 @@ if (common.hasCrypto) { } test(http); - -process.on('exit', function() { - assert.equal(actual_bad_requests, expected_bad_requests); -}); diff --git a/test/parallel/test-http-full-response.js b/test/parallel/test-http-full-response.js index 17240c9addb895..8472a84fb9fac9 100644 --- a/test/parallel/test-http-full-response.js +++ b/test/parallel/test-http-full-response.js @@ -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); diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index 17d5aa1d8f9575..2354871f804248 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -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) {