blob: 17cbd03b365159349e0d06dbc04611f1d6639781 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use axum::{response::IntoResponse, routing::get};
use crate::state::AppState;
pub mod error;
mod users;
pub fn router() -> axum::Router<AppState> {
axum::Router::new()
.merge(users::router())
.route("/healthcheck", get(healthcheck))
}
pub async fn healthcheck() -> impl IntoResponse {
"success"
}
#[cfg(test)]
mod tests {
use crate::tests::{setup_test_env, TestResult};
use super::*;
use axum::{
body::Body,
http::{Request, StatusCode},
Router,
};
use sqlx::PgPool;
use tower::ServiceExt;
#[sqlx::test]
async fn test_healthcheck_ok(pool: PgPool) -> TestResult {
setup_test_env();
let router = Router::new().merge(router()).with_state(AppState { pool });
let request = Request::builder().uri("/healthcheck").body(Body::empty())?;
let response = router.oneshot(request).await?;
assert_eq!(StatusCode::OK, response.status());
Ok(())
}
}
|