mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: add tests to check error in dns.lookupService.
Added tests to check error in dns.lookupService to increase coverage. PR-URL: https://github.com/nodejs/node/pull/22908 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
2811ae4801
commit
0623aabbe1
20
test/parallel/test-dns-lookupService.js
Normal file
20
test/parallel/test-dns-lookupService.js
Normal file
@ -0,0 +1,20 @@
|
||||
// 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');
|
||||
const dns = require('dns');
|
||||
|
||||
// Stub `getnameinfo` to *always* error.
|
||||
cares.getnameinfo = () => UV_ENOENT;
|
||||
|
||||
assert.throws(
|
||||
() => dns.lookupService('127.0.0.1', 80, common.mustNotCall()),
|
||||
{
|
||||
code: 'ENOENT',
|
||||
message: 'getnameinfo ENOENT 127.0.0.1',
|
||||
syscall: 'getnameinfo'
|
||||
}
|
||||
);
|
Loading…
Reference in New Issue
Block a user