@@ -32,19 +32,31 @@ MONGOMS_MD5_CHECK environment variable`, () => {
3232
3333 const du = new MongoBinaryDownload ( { } ) ;
3434 du . httpDownload = jest . fn ( ) ;
35+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
3536
3637 await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
3738 expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
3839 const callArg1 = ( du . httpDownload as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ;
3940 expect ( callArg1 . agent ) . toBeUndefined ( ) ;
4041 } ) ;
4142
43+ it ( 'should skip download if binary tar exists' , async ( ) => {
44+ const du = new MongoBinaryDownload ( { } ) ;
45+ du . httpDownload = jest . fn ( ) ;
46+ du . locationExists = jest . fn ( ) . mockReturnValue ( true ) ;
47+
48+ await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
49+
50+ expect ( du . httpDownload ) . not . toHaveBeenCalled ( ) ;
51+ } ) ;
52+
4253 it ( 'should pick up proxy from env vars' , async ( ) => {
4354 process . env [ 'yarn_https-proxy' ] = 'http://user:pass@proxy:8080' ;
4455
4556 const du = new MongoBinaryDownload ( { } ) ;
4657 // $FlowFixMe
4758 du . httpDownload = jest . fn ( ) ;
59+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
4860
4961 await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
5062 expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -59,6 +71,7 @@ MONGOMS_MD5_CHECK environment variable`, () => {
5971
6072 const du = new MongoBinaryDownload ( { } ) ;
6173 du . httpDownload = jest . fn ( ) ;
74+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
6275
6376 await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
6477 expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -73,6 +86,7 @@ MONGOMS_MD5_CHECK environment variable`, () => {
7386
7487 const du = new MongoBinaryDownload ( { } ) ;
7588 du . httpDownload = jest . fn ( ) ;
89+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
7690
7791 await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
7892 expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments