Skip to content

Commit

Permalink
test: refactor test-http-dns-fail
Browse files Browse the repository at this point in the history
* remove counter used to control function execution
* use commont.mustCall to control the function execution
* use const and let instead of var
* use arrow functions

PR-URL: #10243
Reviewed-By: Italo A. Casas <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Lance Ball <[email protected]>
Reviewed-By: Brian White <[email protected]>
  • Loading branch information
edsadr authored and MylesBorins committed Jan 31, 2017
1 parent 2f64d5a commit 373755c
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions test/internet/test-http-dns-fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,25 @@
*/

const common = require('../common');
var assert = require('assert');
var http = require('http');

var hadError = 0;
const assert = require('assert');
const http = require('http');

function httpreq(count) {
if (1 < count) return;
if (count > 1) return;

var req = http.request({
const req = http.request({
host: 'not-a-real-domain-name.nobody-would-register-this-as-a-tld',
port: 80,
path: '/',
method: 'GET'
}, common.fail);

req.on('error', function(e) {
console.log(e.message);
req.on('error', common.mustCall((e) => {
assert.strictEqual(e.code, 'ENOTFOUND');
hadError++;
httpreq(count + 1);
});
}));

req.end();
}

httpreq(0);


process.on('exit', function() {
assert.equal(2, hadError);
});

0 comments on commit 373755c

Please sign in to comment.