From 3e4af49157343e5e3fa54082d064bfda0ad0dc31 Mon Sep 17 00:00:00 2001 From: Masashi Hirano Date: Thu, 20 Sep 2018 01:33:52 +0900 Subject: [PATCH] test: add dns.onlookupall() to increase coverage Added test that callback should be called when error occurs in dns.lookupall(). PR-URL: https://github.com/nodejs/node/pull/22985 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/internet/test-dns-lookup.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/internet/test-dns-lookup.js b/test/internet/test-dns-lookup.js index b84f80735fb866..df5ccf99a56fc3 100644 --- a/test/internet/test-dns-lookup.js +++ b/test/internet/test-dns-lookup.js @@ -1,7 +1,9 @@ 'use strict'; require('../common'); -const dnsPromises = require('dns').promises; +const common = require('../common'); +const dns = require('dns'); +const dnsPromises = dns.promises; const { addresses } = require('../common/internet'); const assert = require('assert'); @@ -28,3 +30,17 @@ assert.rejects( message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}` } ); + +dns.lookup(addresses.INVALID_HOST, { + hints: 0, + family: 0, + all: true +}, common.mustCall((error) => { + assert.strictEqual(error.code, 'ENOTFOUND'); + assert.strictEqual( + error.message, + `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}` + ); + assert.strictEqual(error.syscall, 'getaddrinfo'); + assert.strictEqual(error.hostname, addresses.INVALID_HOST); +}));