mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
a58f37720d
Added test that callback should be called when error occurs in dns.lookupall(). PR-URL: https://github.com/nodejs/node/pull/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>
47 lines
1017 B
JavaScript
47 lines
1017 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const common = require('../common');
|
|
const dns = require('dns');
|
|
const dnsPromises = dns.promises;
|
|
const { addresses } = require('../common/internet');
|
|
const assert = require('assert');
|
|
|
|
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(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);
|
|
}));
|