File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,29 @@ describe('Tool Tests', function () {
132
132
} ) ;
133
133
} ) ;
134
134
135
+ it ( 'different content-length and file size on disk' , async function ( ) {
136
+ const headers : nock . ReplyHeaders = { 'content-length' : '200' } ;
137
+ nock ( 'https://microsoft.com' )
138
+ . get ( '/bytes/36' )
139
+ . reply ( 200 , {
140
+ username : 'bad' ,
141
+ password : 'size'
142
+ } , headers ) ;
143
+
144
+ return new Promise < void > ( async ( resolve , reject ) => {
145
+ try {
146
+ let errorCodeUrl : string = "https://microsoft.com/bytes/36" ;
147
+ let downPath : string = await toolLib . downloadTool ( errorCodeUrl ) ;
148
+
149
+ reject ( 'content-length of file and size of file on disk should not match, but they do' ) ;
150
+ }
151
+ catch ( err ) {
152
+ assert . equal ( err . message , `Content-Length (200 bytes) did not match downloaded file size (36 bytes).` ) ;
153
+ resolve ( ) ;
154
+ }
155
+ } ) ;
156
+ } ) ;
157
+
135
158
it ( 'works with redirect code 302' , async function ( ) {
136
159
nock ( 'https://microsoft.com' )
137
160
. get ( '/redirect-to' )
Original file line number Diff line number Diff line change @@ -259,7 +259,8 @@ export async function downloadTool(
259
259
if ( ! isNaN ( downloadedContentLength ) &&
260
260
! isNaN ( fileSizeInBytes ) &&
261
261
fileSizeInBytes !== downloadedContentLength ) {
262
- reject ( new Error ( `Content-Length (${ downloadedContentLength } bytes) did not match downloaded file size (${ fileSizeInBytes } bytes).` ) ) ;
262
+ let err : Error = new Error ( `Content-Length (${ downloadedContentLength } bytes) did not match downloaded file size (${ fileSizeInBytes } bytes).` ) ;
263
+ reject ( err ) ;
263
264
}
264
265
265
266
resolve ( destPath ) ;
You can’t perform that action at this time.
0 commit comments