Skip to content

Commit bde485e

Browse files
Trottcodebytere
authored andcommitted
test: add test-dns-promises-lookupService
This adds covereage for the onlookupservice() callback in lib/internal/dns/promises.js. Because of stubbing in other tests, it is not currently covered. This test works on my local development machine with the network turned off, so I'm putting it in parallel. If CI proves more challenging, it can be moved to the internet directory instead. PR-URL: #31640 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent 63bb634 commit bde485e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
const assert = require('assert');
6+
const dnsPromises = require('dns').promises;
7+
8+
dnsPromises.lookupService('127.0.0.1', 22).then(common.mustCall((result) => {
9+
assert.strictEqual(result.service, 'ssh');
10+
assert.strictEqual(typeof result.hostname, 'string');
11+
assert.notStrictEqual(result.hostname.length, 0);
12+
}));
13+
14+
// Use an IP from the RFC 5737 test range to cause an error.
15+
// Refs: https://tools.ietf.org/html/rfc5737
16+
assert.rejects(
17+
() => dnsPromises.lookupService('192.0.2.1', 22),
18+
{ code: /^(?:ENOTFOUND|EAI_AGAIN)$/ }
19+
);

0 commit comments

Comments
 (0)