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 {
39
39
const status = response . status ;
40
40
if ( status === 200 ) {
41
41
return true ;
42
- } else if ( status === 404 ) {
42
+ }
43
+ if ( status === 404 ) {
43
44
if ( path === '/healthz' ) {
44
45
// /livez/readyz return 404 and healthz also returns 404, let's consider it is live
45
46
return true ;
46
47
}
47
48
return this . healthz ( opts ) ;
48
- } else {
49
- return false ;
50
49
}
51
- } catch {
52
50
return false ;
51
+ } catch {
52
+ throw new Error ( 'Error occurred in health request' ) ;
53
53
}
54
54
}
55
55
}
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ describe('Health', () => {
124
124
scope . done ( ) ;
125
125
} ) ;
126
126
127
- it ( 'should return false when fetch throws an error' , async ( ) => {
127
+ it ( 'should throw an error when fetch throws an error' , async ( ) => {
128
128
const kc = new KubeConfig ( ) ;
129
129
const cluster = {
130
130
name : 'foo' ,
@@ -141,8 +141,7 @@ describe('Health', () => {
141
141
scope . get ( '/livez' ) . replyWithError ( new Error ( 'an error' ) ) ;
142
142
const health = new Health ( kc ) ;
143
143
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' ) ;
146
145
scope . done ( ) ;
147
146
} ) ;
148
147
} ) ;
You can’t perform that action at this time.
0 commit comments