Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
test: move test that depends on dns query to internet
These test cases in `test/parallel/test-dns-lookup.js` send
dns requests and depend on the results, which could fail
if the DNS service for invalid hosts is hijacked by the ISP.
  • Loading branch information
joyeecheung committed Aug 25, 2018
commit 0e8de282f2a280c69e976cd47b22d7e1bb6260f6
30 changes: 30 additions & 0 deletions test/internet/test-dns-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

require('../common');
const dnsPromises = require('dns').promises;
const { addresses } = require('../common/internet');
const assert = require('assert');

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: false
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: true
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);
25 changes: 0 additions & 25 deletions test/parallel/test-dns-lookup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');
const { addresses } = require('../common/internet');
const assert = require('assert');
const cares = process.binding('cares_wrap');
const dns = require('dns');
Expand Down Expand Up @@ -96,30 +95,6 @@ common.expectsError(() => {
all: false
});
assert.deepStrictEqual(res, { address: '127.0.0.1', family: 4 });

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: false
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);

assert.rejects(
dnsPromises.lookup(addresses.INVALID_HOST, {
hints: 0,
family: 0,
all: true
}),
{
code: 'ENOTFOUND',
message: `getaddrinfo ENOTFOUND ${addresses.INVALID_HOST}`
}
);
})();

dns.lookup(false, {
Expand Down