mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8f742bb13f
PR-URL: https://github.com/nodejs/node/pull/50318 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
36 lines
956 B
JavaScript
36 lines
956 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const cares = internalBinding('cares_wrap');
|
|
const { UV_ENOENT } = internalBinding('uv');
|
|
|
|
// Stub `getnameinfo` to *always* error.
|
|
cares.getnameinfo = () => UV_ENOENT;
|
|
|
|
// Because dns promises is attached lazily,
|
|
// and turn accesses getnameinfo on init
|
|
// but this lazy access is triggered by ES named
|
|
// instead of lazily itself, we must require
|
|
// dns after hooking cares
|
|
const dns = require('dns');
|
|
|
|
assert.throws(
|
|
() => dns.lookupService('127.0.0.1', 80, common.mustNotCall()),
|
|
{
|
|
code: 'ENOENT',
|
|
message: 'getnameinfo ENOENT 127.0.0.1',
|
|
syscall: 'getnameinfo'
|
|
}
|
|
);
|
|
|
|
assert.rejects(
|
|
dns.promises.lookupService('127.0.0.1', 80),
|
|
{
|
|
code: 'ENOENT',
|
|
message: 'getnameinfo ENOENT 127.0.0.1',
|
|
syscall: 'getnameinfo'
|
|
}
|
|
).then(common.mustCall());
|