MCPcopy
hub / github.com/mongodb/node-mongodb-native / configureMongocryptdSpawnHooks

Function configureMongocryptdSpawnHooks

test/tools/utils.ts:593–621  ·  view source on GitHub ↗
(
  options: { port?: string; pidfilepath?: string } = {}
)

Source from the content-addressed store, hash-verified

591})();
592
593export function configureMongocryptdSpawnHooks(
594 options: { port?: string; pidfilepath?: string } = {}
595): { port: string } {
596 const port = options.port ?? '27022';
597 const pidfilepath = options.pidfilepath ?? path.join(tmpdir(), new BSON.ObjectId().toHexString());
598
599 let childProcess: child_process.ChildProcess;
600
601 beforeEach(async function () {
602 childProcess = child_process.spawn(
603 'mongocryptd',
604 ['--port', port, '--ipv6', '--pidfilepath', pidfilepath],
605 {
606 stdio: 'ignore',
607 detached: false
608 }
609 );
610
611 childProcess.on('error', error => console.warn(this.currentTest?.fullTitle(), error));
612 });
613
614 afterEach(function () {
615 childProcess.kill('SIGKILL');
616 });
617
618 return {
619 port
620 };
621}
622
623/**
624 * A `Runtime` that resolves to entirely Nodejs modules, useful when tests must provide a default `runtime` object to an API.

Calls 2

spawnMethod · 0.80
onMethod · 0.80

Tested by

no test coverage detected