11import { ChildProcess } from 'child_process' ;
22import tmp from 'tmp' ;
33import getPort from 'get-port' ;
4- // import Debug from 'debug'; // TODO : Do we really need this package ?
54import { generateDbName } from './util/db_util' ;
65import MongoInstance from './util/MongoInstance' ;
76import { MongoBinaryOpts } from './util/MongoBinary' ;
@@ -39,7 +38,6 @@ export interface MongoInstanceDataT {
3938 replSet ?: string ;
4039}
4140
42- // TODO: do we need to keep this function async ?
4341const generateConnectionString = async ( port : number , dbName : string ) : Promise < string > => {
4442 return `mongodb://127.0.0.1:${ port } /${ dbName } ` ;
4543} ;
@@ -101,10 +99,6 @@ export default class MongoMemoryServer {
10199
102100 const instOpts = this . opts . instance ;
103101 data . port = await getPort ( { port : ( instOpts && instOpts . port ) || undefined } ) ;
104- /*
105- this.debug = Debug(`Mongo[${data.port}]`); // TODO: Why do we dont just use this.debug here ?
106- this.debug.enabled = !!this.opts.debug; // Useful ?
107- */
108102 data . dbName = generateDbName ( instOpts && instOpts . dbName ) ;
109103 data . uri = await generateConnectionString ( data . port , data . dbName ) ;
110104 data . storageEngine = ( instOpts && instOpts . storageEngine ) || 'ephemeralForTest' ;
@@ -119,6 +113,7 @@ export default class MongoMemoryServer {
119113 unsafeCleanup : true ,
120114 } ) ;
121115 data . dbPath = tmpDir . name ;
116+ data . tmpDir = tmpDir ;
122117 }
123118
124119 this . debug ( `Starting MongoDB instance with following options: ${ JSON . stringify ( data ) } ` ) ;
@@ -142,7 +137,6 @@ export default class MongoMemoryServer {
142137 } ) ;
143138 data . instance = instance ;
144139 data . childProcess = instance . childProcess ;
145- // data.tmpDir = tmpDir;
146140
147141 return data ;
148142 }
0 commit comments