mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
test: add tests for dnsPromises.lookup
Added tests for dnsPromises.lookup to increase coverage and test `onlookup()` and `onlookupall()` methods. PR-URL: https://github.com/nodejs/node/pull/21559 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
1 parent
7794d4e0b8
commit
ae016c8e6d
1 file changed
+25
@@ -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');
|
||||
@@ -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, {
|
||||
|
||||
Reference in new issue
Block a user