@@ -88,6 +88,20 @@ beforeEach(() => {
88
88
} )
89
89
. get ( "/repos/my-enterprise/test-repo/releases/assets/66946546" )
90
90
. replyWithFile ( 200 , __dirname + "/resource/assets/test-1.txt" )
91
+
92
+ nock ( "https://api.github.com/" )
93
+ . get ( "/repos/robinraju/slick-pg/releases" )
94
+ . reply ( 200 , readFromFile ( "4-with-prerelease.json" ) )
95
+
96
+ nock ( "https://api.github.com" , {
97
+ reqheaders : { accept : "application/octet-stream" }
98
+ } )
99
+ . get ( "/repos/robinraju/slick-pg/releases/assets/66946546" )
100
+ . replyWithFile ( 200 , __dirname + "/resource/assets/pre-release.txt" )
101
+
102
+ nock ( "https://api.github.com/" )
103
+ . get ( "/repos/foo/slick-pg/releases" )
104
+ . reply ( 200 , readFromFile ( "5-without-prerelease.json" ) )
91
105
} )
92
106
93
107
afterEach ( async ( ) => {
@@ -104,6 +118,7 @@ test("Download all files from public repo", async () => {
104
118
const downloadSettings : IReleaseDownloadSettings = {
105
119
sourceRepoPath : "robinraju/probable-potato" ,
106
120
isLatest : true ,
121
+ preRelease : false ,
107
122
tag : "" ,
108
123
id : "" ,
109
124
fileName : "*" ,
@@ -120,6 +135,7 @@ test("Download single file from public repo", async () => {
120
135
const downloadSettings : IReleaseDownloadSettings = {
121
136
sourceRepoPath : "robinraju/probable-potato" ,
122
137
isLatest : true ,
138
+ preRelease : false ,
123
139
tag : "" ,
124
140
id : "" ,
125
141
fileName : "test-1.txt" ,
@@ -136,6 +152,7 @@ test("Fail loudly if given filename is not found in a release", async () => {
136
152
const downloadSettings : IReleaseDownloadSettings = {
137
153
sourceRepoPath : "robinraju/probable-potato" ,
138
154
isLatest : true ,
155
+ preRelease : false ,
139
156
tag : "" ,
140
157
id : "" ,
141
158
fileName : "missing-file.txt" ,
@@ -154,6 +171,7 @@ test("Fail loudly if release is not identified", async () => {
154
171
const downloadSettings : IReleaseDownloadSettings = {
155
172
sourceRepoPath : "robinraju/probable-potato" ,
156
173
isLatest : false ,
174
+ preRelease : false ,
157
175
tag : "" ,
158
176
id : "" ,
159
177
fileName : "missing-file.txt" ,
@@ -172,6 +190,7 @@ test("Download files with wildcard from public repo", async () => {
172
190
const downloadSettings : IReleaseDownloadSettings = {
173
191
sourceRepoPath : "robinraju/probable-potato" ,
174
192
isLatest : true ,
193
+ preRelease : false ,
175
194
tag : "" ,
176
195
id : "" ,
177
196
fileName : "test-*.txt" ,
@@ -188,6 +207,7 @@ test("Download single file with wildcard from public repo", async () => {
188
207
const downloadSettings : IReleaseDownloadSettings = {
189
208
sourceRepoPath : "robinraju/probable-potato" ,
190
209
isLatest : true ,
210
+ preRelease : false ,
191
211
tag : "" ,
192
212
id : "" ,
193
213
fileName : "3-*.txt" ,
@@ -204,6 +224,7 @@ test("Download multiple pdf files with wildcard filename", async () => {
204
224
const downloadSettings : IReleaseDownloadSettings = {
205
225
sourceRepoPath : "robinraju/probable-potato" ,
206
226
isLatest : true ,
227
+ preRelease : false ,
207
228
tag : "" ,
208
229
id : "" ,
209
230
fileName : "*.pdf" ,
@@ -220,6 +241,7 @@ test("Download a csv file with wildcard filename", async () => {
220
241
const downloadSettings : IReleaseDownloadSettings = {
221
242
sourceRepoPath : "robinraju/probable-potato" ,
222
243
isLatest : true ,
244
+ preRelease : false ,
223
245
tag : "" ,
224
246
id : "" ,
225
247
fileName : "*.csv" ,
@@ -238,6 +260,7 @@ test("Download file from Github Enterprise server", async () => {
238
260
const downloadSettings : IReleaseDownloadSettings = {
239
261
sourceRepoPath : "my-enterprise/test-repo" ,
240
262
isLatest : true ,
263
+ preRelease : false ,
241
264
tag : "" ,
242
265
id : "" ,
243
266
fileName : "test-1.txt" ,
@@ -254,6 +277,7 @@ test("Download file from release identified by ID", async () => {
254
277
const downloadSettings : IReleaseDownloadSettings = {
255
278
sourceRepoPath : "robinraju/probable-potato" ,
256
279
isLatest : false ,
280
+ preRelease : false ,
257
281
tag : "" ,
258
282
id : "68092191" ,
259
283
fileName : "test-2.txt" ,
@@ -270,6 +294,7 @@ test("Download all archive files from public repo", async () => {
270
294
const downloadSettings : IReleaseDownloadSettings = {
271
295
sourceRepoPath : "robinraju/probable-potato" ,
272
296
isLatest : true ,
297
+ preRelease : false ,
273
298
tag : "" ,
274
299
id : "" ,
275
300
fileName : "*.zip" ,
@@ -295,6 +320,7 @@ test("Fail when a release with no assets are obtained", async () => {
295
320
const downloadSettings : IReleaseDownloadSettings = {
296
321
sourceRepoPath : "robinraju/foo-app" ,
297
322
isLatest : false ,
323
+ preRelease : false ,
298
324
tag : "1.0.0" ,
299
325
id : "" ,
300
326
fileName : "installer.zip" ,
@@ -308,3 +334,37 @@ test("Fail when a release with no assets are obtained", async () => {
308
334
"No assets found in release Foo app - v1.0.0"
309
335
)
310
336
} , 10000 )
337
+
338
+ test ( "Download from latest prerelease" , async ( ) => {
339
+ const downloadSettings : IReleaseDownloadSettings = {
340
+ sourceRepoPath : "robinraju/slick-pg" ,
341
+ isLatest : true ,
342
+ preRelease : true ,
343
+ tag : "" ,
344
+ id : "" ,
345
+ fileName : "pre-release.txt" ,
346
+ tarBall : false ,
347
+ zipBall : false ,
348
+ extractAssets : false ,
349
+ outFilePath : outputFilePath
350
+ }
351
+ const result = await downloader . download ( downloadSettings )
352
+ expect ( result . length ) . toBe ( 1 )
353
+ } , 10000 )
354
+
355
+ test ( "Fail when a release with no prerelease is obtained" , async ( ) => {
356
+ const downloadSettings : IReleaseDownloadSettings = {
357
+ sourceRepoPath : "foo/slick-pg" ,
358
+ isLatest : true ,
359
+ preRelease : true ,
360
+ tag : "" ,
361
+ id : "" ,
362
+ fileName : "installer.zip" ,
363
+ tarBall : false ,
364
+ zipBall : false ,
365
+ extractAssets : false ,
366
+ outFilePath : outputFilePath
367
+ }
368
+ const result = downloader . download ( downloadSettings )
369
+ await expect ( result ) . rejects . toThrow ( "No prereleases found!" )
370
+ } , 10000 )
0 commit comments