feat: add health endpoint and tests
This commit is contained in:
parent
68d50b69dd
commit
7cc4a9301f
1 changed files with 21 additions and 31 deletions
|
@ -69,7 +69,7 @@ async fn health(ctx: crate::AppCtx) -> impl Responder {
|
||||||
|
|
||||||
resp_builder.db(ctx.db.ping().await);
|
resp_builder.db(ctx.db.ping().await);
|
||||||
|
|
||||||
HttpResponse::Ok() //.json(resp_builder.build().unwrap())
|
HttpResponse::Ok().json(resp_builder.build().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn services(cfg: &mut web::ServiceConfig) {
|
pub fn services(cfg: &mut web::ServiceConfig) {
|
||||||
|
@ -100,34 +100,24 @@ pub mod tests {
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[actix_rt::test]
|
#[actix_rt::test]
|
||||||
// async fn health_works_pg() {
|
async fn health_works() {
|
||||||
// let data = crate::tests::pg::get_data().await;
|
use actix_web::test;
|
||||||
// health_works(data).await;
|
|
||||||
// }
|
let settings = Settings::new().unwrap();
|
||||||
//
|
let ctx = AppCtx::new(crate::ctx::Ctx::new(&settings).await);
|
||||||
// #[actix_rt::test]
|
let app = test::init_service(App::new().app_data(ctx.clone()).configure(services)).await;
|
||||||
// async fn health_works_maria() {
|
|
||||||
// let data = crate::tests::maria::get_data().await;
|
let resp = test::call_service(
|
||||||
// health_works(data).await;
|
&app,
|
||||||
// }
|
test::TestRequest::get()
|
||||||
//
|
.uri(API_V1_ROUTES.meta.health)
|
||||||
// pub async fn health_works(data: ArcCtx) {
|
.to_request(),
|
||||||
// println!("{}", API_V1_ROUTES.meta.health);
|
)
|
||||||
// let data = &data;
|
.await;
|
||||||
// let app = get_app!(data).await;
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
//
|
|
||||||
// let resp = test::call_service(
|
let health_resp: super::Health = test::read_body_json(resp).await;
|
||||||
// &app,
|
assert!(health_resp.db);
|
||||||
// test::TestRequest::get()
|
}
|
||||||
// .uri(API_V1_ROUTES.meta.health)
|
|
||||||
// .to_request(),
|
|
||||||
// )
|
|
||||||
// .await;
|
|
||||||
// assert_eq!(resp.status(), StatusCode::OK);
|
|
||||||
//
|
|
||||||
// let health_resp: Health = test::read_body_json(resp).await;
|
|
||||||
// assert!(health_resp.db);
|
|
||||||
// assert_eq!(health_resp.redis, Some(true));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue