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:
parent
eab916c4e8
commit
2118342346
@ -1,6 +1,7 @@
|
|||||||
// Flags: --expose-internals
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const { addresses } = require('../common/internet');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const cares = process.binding('cares_wrap');
|
const cares = process.binding('cares_wrap');
|
||||||
const dns = require('dns');
|
const dns = require('dns');
|
||||||
@ -95,6 +96,30 @@ common.expectsError(() => {
|
|||||||
all: false
|
all: false
|
||||||
});
|
});
|
||||||
assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 });
|
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, {
|
dns.lookup(false, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user