test: allow numeric string for lookupService test

Fixes: https://github.com/nodejs/node/issues/42164

If the given port number isn't associated with any service name,
the `service` resolved from `dns.lookupService` can be a numeric
string representing the port number.

PR-URL: https://github.com/nodejs/node/pull/42596
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
Daeyeon Jeong 2022-04-12 21:27:05 +09:00 committed by GitHub
parent 35d72bf4ec
commit db7fa9f4b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ const assert = require('assert');
const dnsPromises = require('dns').promises;
dnsPromises.lookupService('127.0.0.1', 22).then(common.mustCall((result) => {
assert.strictEqual(result.service, 'ssh');
assert(['ssh', '22'].includes(result.service));
assert.strictEqual(typeof result.hostname, 'string');
assert.notStrictEqual(result.hostname.length, 0);
}));