summaryrefslogtreecommitdiff
path: root/test/parallel/test-dns-setserver-when-querying.js
blob: 12cb1a1ca2a86968bfbe33a68fb6b0ddefaa6efb (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
'use strict';

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

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());

    common.expectsError(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);
  }
}