Skip to content

Commit

Permalink
test: add tests for dnsPromises.lookup
Browse files Browse the repository at this point in the history
Added tests for dnsPromises.lookup to increase coverage and test
`onlookup()` and `onlookupall()` methods.

PR-URL: #21559
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
Masashi Hirano authored and targos committed Sep 3, 2018
1 parent 7794d4e commit ae016c8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/parallel/test-dns-lookup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
const common = require('../common');
const { addresses } = require('../common/internet');
const assert = require('assert');
const cares = process.binding('cares_wrap');
const dns = require('dns');
Expand Down Expand Up @@ -92,6 +93,30 @@ common.expectsError(() => {
all: false
});
assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 });

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: false
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: true
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);
})();

dns.lookup(false, {
Expand Down

0 comments on commit ae016c8

Please sign in to comment.