use axum::Router;
#[tokio::test]
async fn rebind_immediately_after_shutdown() {
const MESSAGE: &str = "Hello, World!";
let app = Router::new().route("/", axum::routing::get(|| async { MESSAGE }));
let handle = sui_http::Builder::new()
.serve(("localhost", 0), app.clone())
.unwrap();
let addr = *handle.local_addr();
let response = reqwest::get(format!("http://{addr}"))
.await
.unwrap()
.bytes()
.await
.unwrap();
assert_eq!(response, MESSAGE.as_bytes());
handle.shutdown().await;
let handle = sui_http::Builder::new()
.serve(addr, app)
.expect("rebinding the port immediately after shutdown failed");
let response = reqwest::get(format!("http://{}", handle.local_addr()))
.await
.unwrap()
.bytes()
.await
.unwrap();
assert_eq!(response, MESSAGE.as_bytes());
}