Skip to content
Closed
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
update based on @addaleax' advise
  • Loading branch information
XadillaX committed Dec 5, 2017
commit f7db3d66eb38aacdee4a67fa0350ded1c60e5230
33 changes: 33 additions & 0 deletions test/parallel/test-dns-setserver-when-querying.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

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

const dns = require('dns');

const goog = [
'8.8.8.8',
'8.8.4.4',
];

{
// Fix https://github.com/nodejs/node/issues/14734
const resolver = new dns.Resolver();
resolver.resolve('localhost', function(err/*, ret*/) {
// nothing
});

assert.throws(() => {
resolver.setServers(goog);
}, common.expectsError({
code: 'ERR_DNS_SET_SERVERS_FAILED',
message: /^c-ares failed to set servers: "There are pending queries\." \[.+\]$/g
}));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tiny nit

You could use common.expectsError(throwingFn, errorObj) instead of assert.throws(throwingFn, common.expectsError(errorObj)).


dns.resolve('localhost', function(err/*, ret*/) {
// nothing
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe use common.mustCall for the noop functions in this test? Or are they actually not called at all? In that case a mustNotCall could be used.


// should not throw
dns.setServers(goog);
}
22 changes: 0 additions & 22 deletions test/parallel/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,3 @@ assert.throws(() => {
code: 'ERR_INVALID_CALLBACK',
type: TypeError
}));

{
// Fix https://github.com/nodejs/node/issues/14734
const resolver = new dns.Resolver();
resolver.resolve('localhost', function(err/*, ret*/) {
// nothing
});

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

dns.resolve('localhost', function(err/*, ret*/) {
// nothing
});

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