pub struct TestServerGuard {
pub url: String,
pub coordinator: Arc<ShutdownCoordinator>,
/* private fields */
}Expand description
Test server guard with automatic graceful shutdown.
This guard automatically performs graceful shutdown when dropped, ensuring proper cleanup of server resources even if the test panics.
§Examples
use reinhardt_testkit::fixtures::*;
use reinhardt_urls::routers::ServerRouter as Router;
#[tokio::test]
async fn test_example() {
let router = Router::new();
let server = test_server_guard(router).await;
let response = reqwest::get(&format!("{}/test", server.url))
.await
.unwrap();
assert_eq!(response.status(), 200);
// Automatic graceful shutdown when server goes out of scope
}Fields§
§url: StringServer URL (e.g., “http://127.0.0.1:12345”)
coordinator: Arc<ShutdownCoordinator>Shutdown coordinator for graceful shutdown
Trait Implementations§
Source§impl Drop for TestServerGuard
impl Drop for TestServerGuard
Auto Trait Implementations§
impl Freeze for TestServerGuard
impl !RefUnwindSafe for TestServerGuard
impl Send for TestServerGuard
impl Sync for TestServerGuard
impl Unpin for TestServerGuard
impl UnsafeUnpin for TestServerGuard
impl !UnwindSafe for TestServerGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more