diff options
author | Masashi Hirano <cherrydog07@gmail.com> | 2018-06-27 18:31:25 +0900 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-08-24 14:42:17 +0200 |
commit | 211834234622f4da6347b1bec04333471a8443e3 (patch) | |
tree | c689f14e8e35a84bd7e53552f275cf45e692c236 /test/parallel/test-dns-lookup.js | |
parent | eab916c4e85eb3930067c3277e681b750fb261d0 (diff) | |
download | android-node-v8-211834234622f4da6347b1bec04333471a8443e3.tar.gz android-node-v8-211834234622f4da6347b1bec04333471a8443e3.tar.bz2 android-node-v8-211834234622f4da6347b1bec04333471a8443e3.zip |
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 <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/parallel/test-dns-lookup.js')
-rw-r--r-- | test/parallel/test-dns-lookup.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js index 99378ce01e..b45393718a 100644 --- a/test/parallel/test-dns-lookup.js +++ b/test/parallel/test-dns-lookup.js @@ -1,6 +1,7 @@ // Flags: --expose-internals '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'); @@ -95,6 +96,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, { |