pub struct TestClient { /* private fields */ }Expand description
An in-process client for a built Server; obtained
via Server::test_client().
Implementations§
Source§impl TestClient
impl TestClient
Sourcepub async fn request(
&self,
method: &str,
path_and_query: &str,
headers: &[(String, String)],
body: Option<Bytes>,
) -> Result<TestResponse>
pub async fn request( &self, method: &str, path_and_query: &str, headers: &[(String, String)], body: Option<Bytes>, ) -> Result<TestResponse>
Performs one request through the real dispatch path and collects the response (streaming bodies included).
Sourcepub async fn send(&self, spec: TestRequest) -> Result<TestResponse>
pub async fn send(&self, spec: TestRequest) -> Result<TestResponse>
Performs a TestRequest: its peer address is what the protection
layer (the rate limiter above all) sees, and its timeout bounds the
whole exchange from the client side, body collection included — so
a stream that never ends fails the test instead of hanging the run.
The exchange runs inside a request span shaped like the one the
live service opens, so log lines carry the request id, method and
path, and the span’s close line is the access-log entry a real
request would produce.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestClient
impl RefUnwindSafe for TestClient
impl Send for TestClient
impl Sync for TestClient
impl Unpin for TestClient
impl UnsafeUnpin for TestClient
impl UnwindSafe for TestClient
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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