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.

27 lines
721 B
Rust

/// Minimal test to debug oneshot() hanging issue.
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");
}