mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
8821860f11
For the initial iteration, only the default resolver can be serialized/deserialized. If `dns.setServers()` has been called, we'll preserve the configured DNS servers in the snapshot. We can consider exposing the serialization method if it becomes necessary for user-land snapshots. PR-URL: https://github.com/nodejs/node/pull/44633 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
35 lines
952 B
JavaScript
35 lines
952 B
JavaScript
'use strict';
|
|
|
|
// This tests support for the dns module in snapshot.
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const fixtures = require('../common/fixtures');
|
|
const { buildSnapshot, runWithSnapshot } = require('../common/snapshot');
|
|
|
|
const entry = fixtures.path('snapshot', 'dns-resolve.js');
|
|
const env = {
|
|
NODE_TEST_HOST: 'localhost',
|
|
NODE_TEST_PROMISE: 'true',
|
|
};
|
|
|
|
tmpdir.refresh();
|
|
function checkOutput(stderr, stdout) {
|
|
// We allow failures as it's not always possible to resolve localhost.
|
|
// Functional tests are done in test/internet instead.
|
|
if (!stderr.startsWith('error:')) {
|
|
assert(stdout.includes('addresses: ['));
|
|
assert.strictEqual(stdout.trim().split('\n').length, 1);
|
|
}
|
|
}
|
|
{
|
|
const { stderr, stdout } = buildSnapshot(entry, env);
|
|
checkOutput(stderr, stdout);
|
|
}
|
|
|
|
{
|
|
const { stderr, stdout } = runWithSnapshot(entry, env);
|
|
checkOutput(stderr, stdout);
|
|
}
|