@@ -32,19 +32,31 @@ MONGOMS_MD5_CHECK environment variable`, () => {
32
32
33
33
const du = new MongoBinaryDownload ( { } ) ;
34
34
du . httpDownload = jest . fn ( ) ;
35
+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
35
36
36
37
await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
37
38
expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
38
39
const callArg1 = ( du . httpDownload as jest . Mock ) . mock . calls [ 0 ] [ 0 ] ;
39
40
expect ( callArg1 . agent ) . toBeUndefined ( ) ;
40
41
} ) ;
41
42
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
+
42
53
it ( 'should pick up proxy from env vars' , async ( ) => {
43
54
process . env [ 'yarn_https-proxy' ] = 'http://user:pass@proxy:8080' ;
44
55
45
56
const du = new MongoBinaryDownload ( { } ) ;
46
57
// $FlowFixMe
47
58
du . httpDownload = jest . fn ( ) ;
59
+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
48
60
49
61
await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
50
62
expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -59,6 +71,7 @@ MONGOMS_MD5_CHECK environment variable`, () => {
59
71
60
72
const du = new MongoBinaryDownload ( { } ) ;
61
73
du . httpDownload = jest . fn ( ) ;
74
+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
62
75
63
76
await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
64
77
expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -73,6 +86,7 @@ MONGOMS_MD5_CHECK environment variable`, () => {
73
86
74
87
const du = new MongoBinaryDownload ( { } ) ;
75
88
du . httpDownload = jest . fn ( ) ;
89
+ du . locationExists = jest . fn ( ) . mockReturnValue ( false ) ;
76
90
77
91
await du . download ( 'https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz' ) ;
78
92
expect ( du . httpDownload ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments