Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add tests to check error in dns.lookupService.
Added tests to check error in dns.lookupService to
increase coverage.
  • Loading branch information
Masashi Hirano committed Sep 17, 2018
commit a6af2a7fab85a49044426cac2bdc0408e99f716b
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 { internalBinding } = require('internal/test/binding');
const cares = internalBinding('cares_wrap');
const dns = require('dns');

// Stub `getnameinfo` to *always* error.
cares.getnameinfo = () => internalBinding('uv').UV_ENOENT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: uv could be assigned to a variable.


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