@@ -12,16 +12,16 @@ describe('MongoBinaryDownload', () => {
12
12
delete process . env . MONGOMS_SKIP_MD5_CHECK ;
13
13
} ) ;
14
14
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 ) ;
18
18
} ) ;
19
19
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 ) ;
25
25
} ) ;
26
26
27
27
it ( 'should use direct download' , async ( ) => {
@@ -56,7 +56,7 @@ MONGOMS_SKIP_MD5_CHECK environment variable`, () => {
56
56
expect ( callArg1 . agent . options . href ) . toBe ( 'http://user:pass@proxy:8080/' ) ;
57
57
} ) ;
58
58
59
- it ( `checkMD5 returns true if md5 of downloaded mongoDBArchive is
59
+ it ( `makeMD5check returns true if md5 of downloaded mongoDBArchive is
60
60
the same as in the reference result` , ( ) => {
61
61
const someMd5 = 'md5' ;
62
62
fs . readFileSync . mockImplementationOnce ( ( ) => `${ someMd5 } fileName` ) ;
@@ -67,33 +67,35 @@ the same as in the reference result`, () => {
67
67
// $FlowFixMe
68
68
du . download = jest . fn ( ( ) => Promise . resolve ( fileWithReferenceMd5 ) ) ;
69
69
const urlToMongoDBArchivePath = 'some-url' ;
70
- return du . checkMD5 ( urlToMongoDBArchivePath , mongoDBArchivePath ) . then ( res => {
70
+ du . checkMD5 = true ;
71
+ return du . makeMD5check ( urlToMongoDBArchivePath , mongoDBArchivePath ) . then ( res => {
71
72
expect ( res ) . toBe ( true ) ;
72
73
expect ( du . download ) . toBeCalledWith ( urlToMongoDBArchivePath ) ;
73
74
expect ( fs . readFileSync ) . toBeCalledWith ( fileWithReferenceMd5 ) ;
74
75
expect ( md5file . sync ) . toBeCalledWith ( mongoDBArchivePath ) ;
75
76
} ) ;
76
77
} ) ;
77
78
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
79
80
the same as in the reference result` , ( ) => {
80
81
fs . readFileSync . mockImplementationOnce ( ( ) => 'someMd5 fileName' ) ;
81
82
md5file . sync . mockImplementationOnce ( ( ) => 'anotherMd5' ) ;
82
83
const du = new MongoBinaryDownload ( { } ) ;
84
+ du . checkMD5 = true ;
83
85
// $FlowFixMe
84
86
du . download = jest . fn ( ( ) => Promise . resolve ( '' ) ) ;
85
- expect ( du . checkMD5 ( '' , '' ) ) . rejects . toMatchInlineSnapshot (
87
+ expect ( du . makeMD5check ( '' , '' ) ) . rejects . toMatchInlineSnapshot (
86
88
`[Error: MongoBinaryDownload: md5 check is failed]`
87
89
) ;
88
90
} ) ;
89
91
90
- it ( 'true value of skipMD5 attribute disables checkMD5 validation' , ( ) => {
92
+ it ( 'false value of checkMD5 attribute disables makeMD5check validation' , ( ) => {
91
93
expect . assertions ( 1 ) ;
92
94
fs . readFileSync . mockImplementationOnce ( ( ) => 'someMd5 fileName' ) ;
93
95
md5file . sync . mockImplementationOnce ( ( ) => 'anotherMd5' ) ;
94
96
const du = new MongoBinaryDownload ( { } ) ;
95
- du . skipMD5 = true ;
96
- return du . checkMD5 ( '' , '' ) . then ( res => {
97
+ du . checkMD5 = false ;
98
+ return du . makeMD5check ( '' , '' ) . then ( res => {
97
99
expect ( res ) . toBe ( undefined ) ;
98
100
} ) ;
99
101
} ) ;
0 commit comments