You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
Rust
52 lines
1.4 KiB
Rust
/// Minimal tests to debug oneshot() hanging issue.
|
|
mod common;
|
|
|
|
use axum::body::Body;
|
|
use axum::http::{Request, StatusCode};
|
|
use axum::{routing::get, Router};
|
|
use http_body_util::BodyExt;
|
|
use tower::ServiceExt;
|
|
|
|
async fn hello() -> &'static str {
|
|
"ok"
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn minimal_oneshot_works() {
|
|
let app: Router = Router::new().route("/test", get(hello));
|
|
|
|
let req: Request<Body> = Request::builder()
|
|
.uri("/test")
|
|
.body(Body::empty())
|
|
.unwrap();
|
|
|
|
let response: axum::http::Response<Body> = app.oneshot(req).await.unwrap();
|
|
assert_eq!(response.status(), StatusCode::OK);
|
|
|
|
let body = response.into_body().collect().await.unwrap().to_bytes();
|
|
assert_eq!(&body[..], b"ok");
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn full_app_health_check() {
|
|
if std::env::var("TEST_DATABASE_URL").is_err() {
|
|
eprintln!("SKIPPED: TEST_DATABASE_URL not set");
|
|
return;
|
|
}
|
|
|
|
eprintln!("Creating TestApp...");
|
|
let app = common::TestApp::new().await;
|
|
eprintln!("TestApp created. Sending request...");
|
|
|
|
let req: Request<Body> = Request::builder()
|
|
.uri("/api/v1/health")
|
|
.body(Body::empty())
|
|
.unwrap();
|
|
|
|
eprintln!("Calling oneshot...");
|
|
let response = app.router.clone().oneshot(req).await.unwrap();
|
|
eprintln!("Got response: {}", response.status());
|
|
|
|
assert_eq!(response.status(), StatusCode::OK);
|
|
}
|