summaryrefslogtreecommitdiff
path: root/test/parallel/test-dns-setserver-when-querying.js
blob: 0432f2d4655a078044fc0c4139c1ede92c12de5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';

const common = require('../common');

const assert = require('assert');
const dns = require('dns');

const localhost = [ '127.0.0.1' ];

{
  // Fix https://github.com/nodejs/node/issues/14734

  {
    const resolver = new dns.Resolver();
    resolver.resolve('localhost', common.mustCall());

    assert.throws(resolver.setServers.bind(resolver, localhost), {
      code: 'ERR_DNS_SET_SERVERS_FAILED',
      message: /^c-ares failed to set servers: "There are pending queries\." \[.+\]$/g
    });
  }

  {
    dns.resolve('localhost', common.mustCall());

    // should not throw
    dns.setServers(localhost);
  }
}