File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -39,17 +39,17 @@ export class Health {
3939 const status = response . status ;
4040 if ( status === 200 ) {
4141 return true ;
42- } else if ( status === 404 ) {
42+ }
43+ if ( status === 404 ) {
4344 if ( path === '/healthz' ) {
4445 // /livez/readyz return 404 and healthz also returns 404, let's consider it is live
4546 return true ;
4647 }
4748 return this . healthz ( opts ) ;
48- } else {
49- return false ;
5049 }
51- } catch {
5250 return false ;
51+ } catch {
52+ throw new Error ( 'Error occurred in health request' ) ;
5353 }
5454 }
5555}
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ describe('Health', () => {
124124 scope . done ( ) ;
125125 } ) ;
126126
127- it ( 'should return false when fetch throws an error' , async ( ) => {
127+ it ( 'should throw an error when fetch throws an error' , async ( ) => {
128128 const kc = new KubeConfig ( ) ;
129129 const cluster = {
130130 name : 'foo' ,
@@ -141,8 +141,7 @@ describe('Health', () => {
141141 scope . get ( '/livez' ) . replyWithError ( new Error ( 'an error' ) ) ;
142142 const health = new Health ( kc ) ;
143143
144- const r = await health . livez ( { } ) ;
145- expect ( r ) . to . be . false ;
144+ await expect ( health . livez ( { } ) ) . to . be . rejectedWith ( 'Error occurred in health request' ) ;
146145 scope . done ( ) ;
147146 } ) ;
148147 } ) ;
You can’t perform that action at this time.
0 commit comments