Skip to content

Commit

Permalink
test: add dns.onlookupall() to increase coverage
Browse files Browse the repository at this point in the history
Added test that callback should be called when error occurs
in dns.lookupall().

PR-URL: #22985
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Masashi Hirano authored and targos committed Sep 27, 2018
1 parent d68dfa9 commit 3e4af49
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/internet/test-dns-lookup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

require('../common');
const dnsPromises = require('dns').promises;
const common = require('../common');
const dns = require('dns');
const dnsPromises = dns.promises;
const { addresses } = require('../common/internet');
const assert = require('assert');

Expand All @@ -28,3 +30,17 @@ assert.rejects(
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);

dns.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: true
}, common.mustCall((error) => {
assert.strictEqual(error.code, 'ENOTFOUND');
assert.strictEqual(
error.message,
`getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
);
assert.strictEqual(error.syscall, 'getaddrinfo');
assert.strictEqual(error.hostname, addresses.INVALID_HOST);
}));

0 comments on commit 3e4af49

Please sign in to comment.