File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed
build-tests/rush-amazon-s3-build-cache-plugin-integration-test
rush-plugins/rush-amazon-s3-build-cache-plugin/src Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ In this folder run `docker-compose down`
17
17
rushx read-s3-object
18
18
```
19
19
20
- # Test retries
20
+ # Testing retries
21
21
22
22
To test that requests can be retried start the proxy server which will fail every second request:
23
23
Original file line number Diff line number Diff line change @@ -152,6 +152,12 @@ export class AmazonS3Client {
152
152
) {
153
153
// unauthorized due to not providing credentials,
154
154
// silence error for better DX when e.g. running locally without credentials
155
+ this . _writeWarningLine (
156
+ `No credentials found and received a ${ response . status } ` ,
157
+ ' response code from the cloud storage.' ,
158
+ ' Maybe run rush update-cloud-credentials' ,
159
+ ' or set the RUSH_BUILD_CACHE_CREDENTIAL env'
160
+ ) ;
155
161
return {
156
162
hasNetworkError : false ,
157
163
response : undefined
@@ -193,7 +199,16 @@ export class AmazonS3Client {
193
199
try {
194
200
this . _terminal . writeDebugLine ( ...messageParts ) ;
195
201
} catch ( err ) {
196
- //
202
+ // ignore error
203
+ }
204
+ }
205
+
206
+ private _writeWarningLine ( ...messageParts : ( string | IColorableSequence ) [ ] ) : void {
207
+ // if the terminal has been closed then don't bother sending a warning message
208
+ try {
209
+ this . _terminal . writeWarningLine ( ...messageParts ) ;
210
+ } catch ( err ) {
211
+ // ignore error
197
212
}
198
213
}
199
214
Original file line number Diff line number Diff line change @@ -452,10 +452,15 @@ describe(AmazonS3Client.name, () => {
452
452
453
453
for ( const code of [ 400 , 401 , 403 ] ) {
454
454
it ( `Handles missing credentials object when ${ code } ` , async ( ) => {
455
- const result : Buffer | undefined = await makeGetRequestAsync (
455
+ let warningSpy : jest . SpyInstance < any , unknown [ ] > | undefined ;
456
+ const result : Buffer | undefined = await makeS3ClientRequestAsync (
456
457
undefined ,
457
458
DUMMY_OPTIONS ,
458
- 'abc123' ,
459
+ async ( s3Client ) => {
460
+ ( s3Client as any ) . _writeWarningLine = ( ) => { } ;
461
+ warningSpy = jest . spyOn ( s3Client as any , '_writeWarningLine' ) ;
462
+ return await s3Client . getObjectAsync ( 'abc123' ) ;
463
+ } ,
459
464
{
460
465
responseInit : {
461
466
status : code ,
@@ -467,6 +472,13 @@ describe(AmazonS3Client.name, () => {
467
472
}
468
473
) ;
469
474
expect ( result ) . toBeUndefined ( ) ;
475
+ expect ( warningSpy ) . toHaveBeenNthCalledWith (
476
+ 1 ,
477
+ `No credentials found and received a ${ code } ` ,
478
+ ' response code from the cloud storage.' ,
479
+ ' Maybe run rush update-cloud-credentials' ,
480
+ ' or set the RUSH_BUILD_CACHE_CREDENTIAL env'
481
+ ) ;
470
482
} ) ;
471
483
}
472
484
} ) ;
You can’t perform that action at this time.
0 commit comments