refactor(tests): use axum::serve

This commit is contained in:
藍+85CD 2024-07-25 17:21:46 +08:00
parent c2ba56ee13
commit 8f0fdfaea9
No known key found for this signature in database
GPG key ID: BCB0111111111111
2 changed files with 14 additions and 8 deletions

View file

@ -424,6 +424,7 @@ mod tests {
use bytes::Bytes;
use http::{HeaderMap, StatusCode};
use std::time::Instant;
use tokio::net::TcpListener;
use tracing::debug;
// This will periodically send back internal errors to test the retry
@ -451,10 +452,12 @@ mod tests {
.route("/", post(dodgy_handler))
.with_state(state);
axum::Server::bind(&"0.0.0.0:8002".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
axum::serve(
TcpListener::bind("0.0.0.0:8002").await.unwrap(),
app.into_make_service(),
)
.await
.unwrap();
}
#[tokio::test(flavor = "multi_thread")]

View file

@ -232,6 +232,7 @@ mod tests {
sync::{atomic::AtomicUsize, Arc},
time::Instant,
};
use tokio::net::TcpListener;
use tracing::info;
// This will periodically send back internal errors to test the retry
@ -251,10 +252,12 @@ mod tests {
.route("/", post(dodgy_handler))
.with_state(state);
axum::Server::bind(&"0.0.0.0:8001".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
axum::serve(
TcpListener::bind("0.0.0.0:8002").await.unwrap(),
app.into_make_service(),
)
.await
.unwrap();
}
#[tokio::test(flavor = "multi_thread")]