Skip to content

Commit c34872e

Browse files
Trottcodebytere
authored andcommitted
test,dns: add coverage for dns exception
Add test coverage for dns.promises.resolve() handling an exception from c-ares. Refs: https://coverage.nodejs.org/coverage-d213f21c72f77da6/lib/internal/dns/promises.js.html#L198 PR-URL: #31678 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: David Carlier <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 98f3028 commit c34872e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Flags: --expose-internals
2+
'use strict';
3+
require('../common');
4+
const assert = require('assert');
5+
const { internalBinding } = require('internal/test/binding');
6+
const cares = internalBinding('cares_wrap');
7+
const { UV_EPERM } = internalBinding('uv');
8+
const dnsPromises = require('dns').promises;
9+
10+
// Stub cares to force an error so we can test DNS error code path.
11+
cares.ChannelWrap.prototype.queryA = () => UV_EPERM;
12+
13+
assert.rejects(
14+
dnsPromises.resolve('example.org'),
15+
{
16+
code: 'EPERM',
17+
syscall: 'queryA',
18+
hostname: 'example.org'
19+
}
20+
);

0 commit comments

Comments
 (0)