Skip to content

Commit

Permalink
dns: Add setServers into 'dns/promises'
Browse files Browse the repository at this point in the history
  • Loading branch information
shisama committed Apr 28, 2020
1 parent 69041eb commit 4bfbeff
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/dns/promises.js
@@ -1,3 +1,5 @@
'use strict';

module.exports = require('internal/dns/promises');
const dnsPromises = require('internal/dns/promises');
dnsPromises.setServers = require('dns').setServers;
module.exports = dnsPromises;
35 changes: 35 additions & 0 deletions test/parallel/test-dns-setservers-type-check.js
Expand Up @@ -85,3 +85,38 @@ const promiseResolver = new dns.promises.Resolver();
);
});
}

// This test for 'dns/promises'
{
const {
setServers,
resolve
} = require('dns/promises');

// This should not throw any error.
(async () => {
const localhost = await resolve('localhost');
setServers(localhost);
})();

[
[null],
[undefined],
[Number(addresses.DNS4_SERVER)],
[
{
address: addresses.DNS4_SERVER
}
]
].forEach((val) => {
const errObj = {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError',
message: 'The "servers[0]" argument must be of type string.' +
common.invalidArgTypeHelper(val[0])
};
assert.throws(() => {
setServers(val);
}, errObj);
});
}

0 comments on commit 4bfbeff

Please sign in to comment.