summaryrefslogtreecommitdiff
path: root/test/parallel/test-dns-lookupService.js
blob: 92fce6cbd3f189ee5782491c0b8b076f5b5f93ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// 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 { UV_ENOENT } = internalBinding('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'
  }
);