@@ -247,8 +247,7 @@ describe('awsEksDetector', () => {
247247 } ) ;
248248
249249 describe ( 'on unsuccesful request' , ( ) => {
250- it ( 'should throw when receiving error response code' , async ( ) => {
251- const expectedError = new Error ( 'EKS metadata api request timed out.' ) ;
250+ it ( 'should return an empty resource when timed out' , async ( ) => {
252251 fileStub = sinon
253252 . stub ( AwsEksDetector , 'fileAccessAsync' as any )
254253 . resolves ( ) ;
@@ -265,17 +264,14 @@ describe('awsEksDetector', () => {
265264 . delayConnection ( 2500 )
266265 . reply ( 200 , ( ) => mockedAwsAuth ) ;
267266
268- try {
269- await awsEksDetector . detect ( ) ;
270- } catch ( err ) {
271- assert . deepStrictEqual ( err , expectedError ) ;
272- }
273-
267+ const resource : Resource = await awsEksDetector . detect ( ) ;
274268 scope . done ( ) ;
275- } ) ;
276269
277- it ( 'should return an empty resource when timed out' , async ( ) => {
278- const expectedError = new Error ( 'Failed to load page, status code: 404' ) ;
270+ assert . ok ( resource ) ;
271+ assertEmptyResource ( resource ) ;
272+ } ) . timeout ( awsEksDetector . TIMEOUT_MS + 100 ) ;
273+
274+ it ( 'should return an empty resource when receiving error response code' , async ( ) => {
279275 fileStub = sinon
280276 . stub ( AwsEksDetector , 'fileAccessAsync' as any )
281277 . resolves ( ) ;
@@ -291,13 +287,11 @@ describe('awsEksDetector', () => {
291287 . matchHeader ( 'Authorization' , k8s_token )
292288 . reply ( 404 , ( ) => new Error ( ) ) ;
293289
294- try {
295- await awsEksDetector . detect ( ) ;
296- } catch ( err ) {
297- assert . deepStrictEqual ( err , expectedError ) ;
298- }
299-
290+ const resource : Resource = await awsEksDetector . detect ( ) ;
300291 scope . done ( ) ;
292+
293+ assert . ok ( resource ) ;
294+ assertEmptyResource ( resource ) ;
301295 } ) ;
302296 } ) ;
303297} ) ;
0 commit comments