From ae016c8e6de576c4cc142e76650e9e76b95b4196 Mon Sep 17 00:00:00 2001 From: Masashi Hirano Date: Wed, 27 Jun 2018 18:31:25 +0900 Subject: [PATCH] test: add tests for dnsPromises.lookup Added tests for dnsPromises.lookup to increase coverage and test `onlookup()` and `onlookupall()` methods. PR-URL: https://github.com/nodejs/node/pull/21559 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/parallel/test-dns-lookup.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js index 3413bcffd8abe9..244d2356d9e902 100644 --- a/test/parallel/test-dns-lookup.js +++ b/test/parallel/test-dns-lookup.js @@ -1,5 +1,6 @@ 'use strict'; const common = require('../common'); +const { addresses } = require('../common/internet'); const assert = require('assert'); const cares = process.binding('cares_wrap'); const dns = require('dns'); @@ -92,6 +93,30 @@ common.expectsError(() => { all: false }); assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 }); + + assert.rejects( + dnsPromises.lookup(addresses.INVALID_HOST, { + hints: 0, + family: 0, + all: false + }), + { + code: 'ENOTFOUND', + message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}` + } + ); + + assert.rejects( + dnsPromises.lookup(addresses.INVALID_HOST, { + hints: 0, + family: 0, + all: true + }), + { + code: 'ENOTFOUND', + message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}` + } + ); })(); dns.lookup(false, {