Skip to content

Commit

Permalink
actually call dns.lookup() in tests to avoid cross-environment conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Musinux committed Feb 29, 2024
1 parent 9529279 commit 1975060
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Fs = require('fs');
const Events = require('events');
const Stream = require('stream');
const Zlib = require('zlib');
const Dns = require('dns');

const Boom = require('@hapi/boom');
const Code = require('@hapi/code');
Expand Down Expand Up @@ -1200,19 +1201,17 @@ describe('options.lookup', () => {

it('uses the lookup function to resolve the server ip address', async (flags) => {

const server = await internals.server('ok');
const promise = Wreck.request('get', `http://localhost:${server.address().port}/`, {
lookup: (_hostname, options, callback) => {
let dnsLookupCalled = false;

if (options.all) {
callback(null, [{ address: '127.0.0.1', family: 4 }]);
return;
}
const server = await internals.server('ok');
await Wreck.request('get', `http://localhost:${server.address().port}/`, {
lookup: (hostname, options, callback) => {

callback(null, '127.0.0.1', 4);
dnsLookupCalled = true;
return Dns.lookup(hostname, options, callback);
}
});
await expect(promise).to.not.reject();
expect(dnsLookupCalled).to.equal(true);
flags.onCleanup = () => server.close();
});

Expand Down

0 comments on commit 1975060

Please sign in to comment.