@@ -3,6 +3,7 @@ package api_test
33import (
44 "mokapi/api"
55 "mokapi/config/static"
6+ "mokapi/health"
67 "mokapi/providers/openapi"
78 "mokapi/runtime"
89 "mokapi/runtime/runtimetest"
@@ -218,54 +219,32 @@ func TestHandler_Health(t *testing.T) {
218219 name : "POST is not allowed" ,
219220 cfg : & static.Config {},
220221 test : func (t * testing.T , h http.Handler ) {
221- r := httptest .NewRequest (http .MethodPatch , "http://foo.api/health/live " , nil )
222+ r := httptest .NewRequest (http .MethodPatch , "http://foo.api/health" , nil )
222223 rr := httptest .NewRecorder ()
223224 h .ServeHTTP (rr , r )
224225 require .Equal (t , http .StatusMethodNotAllowed , rr .Code )
225226 },
226227 },
227228 {
228- name : "GET /health/live " ,
229+ name : "GET /health" ,
229230 cfg : & static.Config {},
230231 test : func (t * testing.T , h http.Handler ) {
231- r := httptest .NewRequest (http .MethodGet , "http://foo.api/health/live " , nil )
232+ r := httptest .NewRequest (http .MethodGet , "http://foo.api/health" , nil )
232233 rr := httptest .NewRecorder ()
233234 h .ServeHTTP (rr , r )
234235 require .Equal (t , http .StatusOK , rr .Code )
235- require .Equal (t , `{"status":"alive"}` , rr .Body .String ())
236- },
237- },
238- {
239- name : "GET /health/ready" ,
240- cfg : & static.Config {},
241- test : func (t * testing.T , h http.Handler ) {
242- r := httptest .NewRequest (http .MethodGet , "http://foo.api/health/ready" , nil )
243- rr := httptest .NewRecorder ()
244- h .ServeHTTP (rr , r )
245- require .Equal (t , http .StatusOK , rr .Code )
246- require .Equal (t , `{"status":"ready"}` , rr .Body .String ())
236+ require .Equal (t , `{"status":"healthy"}` , rr .Body .String ())
247237 },
248238 },
249239 {
250240 name : "use path but request does not adapt" ,
251241 cfg : & static.Config {Api : static.Api {Path : "/foo" }},
252242 test : func (t * testing.T , h http.Handler ) {
253- r := httptest .NewRequest (http .MethodGet , "http://foo.api/health/ready" , nil )
254- rr := httptest .NewRecorder ()
255- h .ServeHTTP (rr , r )
256- require .Equal (t , http .StatusOK , rr .Code )
257- require .Equal (t , `{"status":"ready"}` , rr .Body .String ())
258- },
259- },
260- {
261- name : "use path and request adapt" ,
262- cfg : & static.Config {Api : static.Api {Path : "/foo" }},
263- test : func (t * testing.T , h http.Handler ) {
264- r := httptest .NewRequest (http .MethodGet , "http://foo.api/foo/health/ready" , nil )
243+ r := httptest .NewRequest (http .MethodGet , "http://foo.api/health" , nil )
265244 rr := httptest .NewRecorder ()
266245 h .ServeHTTP (rr , r )
267246 require .Equal (t , http .StatusOK , rr .Code )
268- require .Equal (t , `{"status":"ready "}` , rr .Body .String ())
247+ require .Equal (t , `{"status":"healthy "}` , rr .Body .String ())
269248 },
270249 },
271250 }
@@ -277,6 +256,7 @@ func TestHandler_Health(t *testing.T) {
277256 t .Parallel ()
278257
279258 h := api .New (runtime .New (tc .cfg ), tc .cfg .Api )
259+ h .RegisterHealthHandler ("/health" , health .New (static.Health {}))
280260 tc .test (t , h )
281261 })
282262 }
0 commit comments