@@ -8,7 +8,7 @@ import { MongoDBDownloader } from '.';
88
99chai . use ( sinonChai ) ;
1010
11- describe ( 'using locks ' , function ( ) {
11+ describe ( 'MongoDBDownloader ' , function ( ) {
1212 this . timeout ( 60_000 ) ;
1313
1414 let directory : string ;
@@ -135,8 +135,7 @@ describe('using locks', function () {
135135 } ) ,
136136 ] ) ;
137137
138- expect ( result1 . version ) . to . equal ( version ) ;
139- expect ( result2 . version ) . to . equal ( version2 ) ;
138+ expect ( result1 . version ) . to . not . equal ( result2 . version ) ;
140139 expect ( result1 . downloadedBinDir ) . to . not . equal ( result2 . downloadedBinDir ) ;
141140
142141 // Verify both downloaded directories exist and contain mongod
@@ -226,7 +225,6 @@ describe('using locks', function () {
226225
227226 expect ( result1 . version ) . to . equal ( version ) ;
228227 expect ( result2 . version ) . to . equal ( version ) ;
229- expect ( result1 . downloadedBinDir ) . to . equal ( result2 . downloadedBinDir ) ;
230228
231229 // Verify the downloaded directory exists and contains mongod
232230 expect ( await fs . stat ( result1 . downloadedBinDir ) ) . to . be . ok ;
@@ -261,8 +259,7 @@ describe('using locks', function () {
261259 } ) ,
262260 ] ) ;
263261
264- expect ( result1 . version ) . to . equal ( version ) ;
265- expect ( result2 . version ) . to . equal ( version2 ) ;
262+ expect ( result1 . version ) . to . not . equal ( result2 . version ) ;
266263 expect ( result1 . downloadedBinDir ) . to . not . equal ( result2 . downloadedBinDir ) ;
267264
268265 // Verify both downloaded directories exist and contain mongod
@@ -277,4 +274,119 @@ describe('using locks', function () {
277274 expect ( downloadAndExtractStub ) . to . have . been . calledTwice ;
278275 } ) ;
279276 } ) ;
277+
278+ describe ( 'version name' , function ( ) {
279+ for ( const {
280+ version,
281+ enterprise,
282+ expectedVersion,
283+ expectedVersionName,
284+ expectedEnterpriseFlag,
285+ } of [
286+ {
287+ version : '8.1.0' ,
288+ enterprise : undefined ,
289+ expectedVersion : '8.1.0' ,
290+ expectedVersionName : '8.1.0-community' ,
291+ expectedEnterpriseFlag : false ,
292+ } ,
293+ {
294+ version : '8.1.0' ,
295+ enterprise : false ,
296+ expectedVersion : '8.1.0' ,
297+ expectedVersionName : '8.1.0-community' ,
298+ expectedEnterpriseFlag : false ,
299+ } ,
300+ {
301+ version : '8.1.0' ,
302+ enterprise : true ,
303+ expectedVersion : '8.1.0' ,
304+ expectedVersionName : '8.1.0-enterprise' ,
305+ expectedEnterpriseFlag : true ,
306+ } ,
307+ {
308+ version : '8.1.0-enterprise' ,
309+ enterprise : undefined ,
310+ expectedVersion : '8.1.0-enterprise' ,
311+ expectedVersionName : '8.1.0' ,
312+ expectedEnterpriseFlag : true ,
313+ } ,
314+ {
315+ version : '8.1.0-enterprise' ,
316+ enterprise : false ,
317+ expectedVersion : '8.1.0-enterprise' ,
318+ expectedVersionName : '8.1.0-enterprise' ,
319+ expectedEnterpriseFlag : true ,
320+ } ,
321+ {
322+ version : '8.1.0-enterprise' ,
323+ enterprise : true ,
324+ expectedVersion : '8.1.0-enterprise' ,
325+ expectedVersionName : '8.1.0-enterprise' ,
326+ expectedEnterpriseFlag : true ,
327+ } ,
328+ {
329+ version : 'latest-alpha' ,
330+ enterprise : undefined ,
331+ expectedVersion : 'latest-alpha' ,
332+ expectedVersionName : 'latest-alpha' ,
333+ expectedEnterpriseFlag : false ,
334+ } ,
335+ {
336+ version : 'latest-alpha' ,
337+ enterprise : true ,
338+ expectedVersion : 'latest-alpha' ,
339+ expectedVersionName : 'latest-alpha' ,
340+ expectedEnterpriseFlag : true ,
341+ } ,
342+ {
343+ version : '7.0.5' ,
344+ enterprise : false ,
345+ expectedVersion : '7.0.5' ,
346+ expectedVersionName : '7.0.5-community' ,
347+ expectedEnterpriseFlag : false ,
348+ } ,
349+ {
350+ version : '8.1.0-rc0' ,
351+ enterprise : false ,
352+ expectedVersion : '8.1.0-rc0' ,
353+ expectedVersionName : '8.1.0-rc0-community' ,
354+ expectedEnterpriseFlag : false ,
355+ } ,
356+ ] ) {
357+ it ( `should resolve correct version for ${ version } with enterprise=${ String ( enterprise ) } ` , async function ( ) {
358+ lookupDownloadUrlStub . resetHistory ( ) ;
359+
360+ const opts : {
361+ directory : string ;
362+ version : string ;
363+ useLockfile : boolean ;
364+ downloadOptions ?: { enterprise : boolean } ;
365+ } = {
366+ directory,
367+ version,
368+ useLockfile : false ,
369+ } ;
370+
371+ if ( enterprise !== undefined ) {
372+ opts . downloadOptions = { enterprise : enterprise } ;
373+ }
374+
375+ const result =
376+ await testDownloader . downloadMongoDbWithVersionInfo ( opts ) ;
377+
378+ // Verify lookup call
379+ expect ( lookupDownloadUrlStub ) . to . have . been . calledOnce ;
380+
381+ const callArgs = lookupDownloadUrlStub . firstCall . args [ 0 ] ;
382+ expect ( callArgs . targetVersion ) . to . equal ( expectedVersion ) ;
383+ expect ( callArgs . enterprise ) . to . equal ( expectedEnterpriseFlag ) ;
384+
385+ // Verify path contains expected string
386+ expect ( result . downloadedBinDir ) . to . include (
387+ expectedVersionName . replaceAll ( '.' , '' ) ,
388+ ) ;
389+ } ) ;
390+ }
391+ } ) ;
280392} ) ;
0 commit comments