Skip to content

Commit dcce2d6

Browse files
Masashi Hiranotargos
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 fb68ef2 commit dcce2d6

File tree

1 file changed

+19
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)