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 bytes::Bytes;
use http::{HeaderMap, StatusCode}; use http::{HeaderMap, StatusCode};
use std::time::Instant; use std::time::Instant;
use tokio::net::TcpListener;
use tracing::debug; use tracing::debug;
// This will periodically send back internal errors to test the retry // This will periodically send back internal errors to test the retry
@ -451,8 +452,10 @@ mod tests {
.route("/", post(dodgy_handler)) .route("/", post(dodgy_handler))
.with_state(state); .with_state(state);
axum::Server::bind(&"0.0.0.0:8002".parse().unwrap()) axum::serve(
.serve(app.into_make_service()) TcpListener::bind("0.0.0.0:8002").await.unwrap(),
app.into_make_service(),
)
.await .await
.unwrap(); .unwrap();
} }

View file

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