@@ -12,16 +12,16 @@ describe('MongoBinaryDownload', () => {
1212 delete process . env . MONGOMS_SKIP_MD5_CHECK ;
1313 } ) ;
1414
15- it ( 'skipMD5 attribute can be set via constructor parameter' , ( ) => {
16- expect ( new MongoBinaryDownload ( { skipMD5 : true } ) . skipMD5 ) . toBe ( true ) ;
17- expect ( new MongoBinaryDownload ( { skipMD5 : false } ) . skipMD5 ) . toBe ( false ) ;
15+ it ( 'checkMD5 attribute can be set via constructor parameter' , ( ) => {
16+ expect ( new MongoBinaryDownload ( { checkMD5 : true } ) . checkMD5 ) . toBe ( true ) ;
17+ expect ( new MongoBinaryDownload ( { checkMD5 : false } ) . checkMD5 ) . toBe ( false ) ;
1818 } ) ;
1919
20- it ( `if skipMD5 input parameter is missing, then it checks
21- MONGOMS_SKIP_MD5_CHECK environment variable`, ( ) => {
22- expect ( new MongoBinaryDownload ( { } ) . skipMD5 ) . toBe ( false ) ;
23- process . env . MONGOMS_SKIP_MD5_CHECK = '1' ;
24- expect ( new MongoBinaryDownload ( { } ) . skipMD5 ) . toBe ( true ) ;
20+ it ( `if checkMD5 input parameter is missing, then it checks
21+ MONGOMS_MD5_CHECK environment variable`, ( ) => {
22+ expect ( new MongoBinaryDownload ( { } ) . checkMD5 ) . toBe ( false ) ;
23+ process . env . MONGOMS_MD5_CHECK = '1' ;
24+ expect ( new MongoBinaryDownload ( { } ) . checkMD5 ) . toBe ( true ) ;
2525 } ) ;
2626
2727 it ( 'should use direct download' , async ( ) => {
@@ -56,7 +56,7 @@ MONGOMS_SKIP_MD5_CHECK environment variable`, () => {
5656 expect ( callArg1 . agent . options . href ) . toBe ( 'http://user:pass@proxy:8080/' ) ;
5757 } ) ;
5858
59- it ( `checkMD5 returns true if md5 of downloaded mongoDBArchive is
59+ it ( `makeMD5check returns true if md5 of downloaded mongoDBArchive is
6060the same as in the reference result` , ( ) => {
6161 const someMd5 = 'md5' ;
6262 fs . readFileSync . mockImplementationOnce ( ( ) => `${ someMd5 } fileName` ) ;
@@ -67,33 +67,35 @@ the same as in the reference result`, () => {
6767 // $FlowFixMe
6868 du . download = jest . fn ( ( ) => Promise . resolve ( fileWithReferenceMd5 ) ) ;
6969 const urlToMongoDBArchivePath = 'some-url' ;
70- return du . checkMD5 ( urlToMongoDBArchivePath , mongoDBArchivePath ) . then ( res => {
70+ du . checkMD5 = true ;
71+ return du . makeMD5check ( urlToMongoDBArchivePath , mongoDBArchivePath ) . then ( res => {
7172 expect ( res ) . toBe ( true ) ;
7273 expect ( du . download ) . toBeCalledWith ( urlToMongoDBArchivePath ) ;
7374 expect ( fs . readFileSync ) . toBeCalledWith ( fileWithReferenceMd5 ) ;
7475 expect ( md5file . sync ) . toBeCalledWith ( mongoDBArchivePath ) ;
7576 } ) ;
7677 } ) ;
7778
78- it ( `checkMD5 throws an error if md5 of downloaded mongoDBArchive is NOT
79+ it ( `makeMD5check throws an error if md5 of downloaded mongoDBArchive is NOT
7980 the same as in the reference result` , ( ) => {
8081 fs . readFileSync . mockImplementationOnce ( ( ) => 'someMd5 fileName' ) ;
8182 md5file . sync . mockImplementationOnce ( ( ) => 'anotherMd5' ) ;
8283 const du = new MongoBinaryDownload ( { } ) ;
84+ du . checkMD5 = true ;
8385 // $FlowFixMe
8486 du . download = jest . fn ( ( ) => Promise . resolve ( '' ) ) ;
85- expect ( du . checkMD5 ( '' , '' ) ) . rejects . toMatchInlineSnapshot (
87+ expect ( du . makeMD5check ( '' , '' ) ) . rejects . toMatchInlineSnapshot (
8688 `[Error: MongoBinaryDownload: md5 check is failed]`
8789 ) ;
8890 } ) ;
8991
90- it ( 'true value of skipMD5 attribute disables checkMD5 validation' , ( ) => {
92+ it ( 'false value of checkMD5 attribute disables makeMD5check validation' , ( ) => {
9193 expect . assertions ( 1 ) ;
9294 fs . readFileSync . mockImplementationOnce ( ( ) => 'someMd5 fileName' ) ;
9395 md5file . sync . mockImplementationOnce ( ( ) => 'anotherMd5' ) ;
9496 const du = new MongoBinaryDownload ( { } ) ;
95- du . skipMD5 = true ;
96- return du . checkMD5 ( '' , '' ) . then ( res => {
97+ du . checkMD5 = false ;
98+ return du . makeMD5check ( '' , '' ) . then ( res => {
9799 expect ( res ) . toBe ( undefined ) ;
98100 } ) ;
99101 } ) ;
0 commit comments