mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
test: refactor test-http-dns-fail
* 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: https://github.com/nodejs/node/pull/10243 Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Lance Ball <lball@redhat.com> Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
committed by
Italo A. Casas
parent
e432c2bfaa
commit
75ac109998
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user