Skip to content

Commit 0623aab

Browse files
Masashi Hiranodanbev
Masashi Hirano
authored andcommitted
test: add tests to check error in dns.lookupService.
Added tests to check error in dns.lookupService to increase coverage. PR-URL: #22908 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Weijia Wang <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 2811ae4 commit 0623aab

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Flags: --expose-internals
2+
'use strict';
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const { internalBinding } = require('internal/test/binding');
6+
const cares = internalBinding('cares_wrap');
7+
const { UV_ENOENT } = internalBinding('uv');
8+
const dns = require('dns');
9+
10+
// Stub `getnameinfo` to *always* error.
11+
cares.getnameinfo = () => UV_ENOENT;
12+
13+
assert.throws(
14+
() => dns.lookupService('127.0.0.1', 80, common.mustNotCall()),
15+
{
16+
code: 'ENOENT',
17+
message: 'getnameinfo ENOENT 127.0.0.1',
18+
syscall: 'getnameinfo'
19+
}
20+
);

0 commit comments

Comments
 (0)