Skip to content

Commit

Permalink
test: add tests to check error in dns.lookupService.
Browse files Browse the repository at this point in the history
Added tests to check error in dns.lookupService to
increase coverage.

PR-URL: #22908
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Masashi Hirano authored and targos committed Sep 20, 2018
1 parent fb68ef2 commit dcce2d6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/parallel/test-dns-lookupService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const assert = require('assert');
const cares = process.binding('cares_wrap');
const { UV_ENOENT } = process.binding('uv');
const dns = require('dns');

// Stub `getnameinfo` to *always* error.
cares.getnameinfo = () => UV_ENOENT;

assert.throws(
() => dns.lookupService('127.0.0.1', 80, common.mustNotCall()),
{
code: 'ENOENT',
message: 'getnameinfo ENOENT 127.0.0.1',
syscall: 'getnameinfo'
}
);

0 comments on commit dcce2d6

Please sign in to comment.