1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

Test HTTP handlers

This commit is contained in:
Quentin Gliech
2022-08-04 16:31:51 +02:00
parent d1147d0bed
commit 2e2c3d54a6
3 changed files with 85 additions and 10 deletions

View File

@@ -28,3 +28,25 @@ pub async fn get(Extension(pool): Extension<PgPool>) -> Result<impl IntoResponse
Ok("ok")
}
#[cfg(test)]
mod tests {
use hyper::{Body, Request, StatusCode};
use tower::ServiceExt;
use super::*;
#[sqlx::test(migrator = "mas_storage::MIGRATOR")]
async fn test_get_health(pool: PgPool) -> Result<(), anyhow::Error> {
let app = crate::test_router(&pool).await?;
let request = Request::builder().uri("/health").body(Body::empty())?;
let response = app.oneshot(request).await?;
assert_eq!(response.status(), StatusCode::OK);
let body = hyper::body::to_bytes(response.into_body()).await?;
assert_eq!(body, "ok");
Ok(())
}
}