pub struct TestRequest<'a, A: Application> { /* private fields */ }Expand description
A pending test request. Chain builder methods then call TestRequest::send.
Implementations§
Source§impl<'a, A: Application> TestRequest<'a, A>
impl<'a, A: Application> TestRequest<'a, A>
Sourcepub fn body_bytes(self, body: Vec<u8>) -> Self
pub fn body_bytes(self, body: Vec<u8>) -> Self
Set the request body to raw bytes.
Sourcepub fn body_json(self, json: &str) -> Self
pub fn body_json(self, json: &str) -> Self
Set the request body to a JSON string, with
Content-Type: application/json.
Sourcepub fn send(self) -> TestResponse
pub fn send(self) -> TestResponse
Dispatch the request and return the response.
Source§impl<'a, S: Send + Sync + 'static> TestRequest<'a, AsyncAppWithState<S>>
impl<'a, S: Send + Sync + 'static> TestRequest<'a, AsyncAppWithState<S>>
Sourcepub async fn send_async(self) -> TestResponse
Available on crate feature http2 only.
pub async fn send_async(self) -> TestResponse
http2 only.Dispatch the request to an App::with_async_state app and await
the handler, as the async servers do (on this runtime when it’s
multi-threaded, else on rws’s rws-async runtime). Use it from
#[tokio::test]: send blocks the test’s thread while
the handler runs, so on a single-threaded test runtime anything made
on it — a PostgreSQL or MySQL DbPool’s connections — can’t make
progress meanwhile.
Auto Trait Implementations§
impl<'a, A> Freeze for TestRequest<'a, A>where
&'a TestClient<A>: Freeze,
impl<'a, A> RefUnwindSafe for TestRequest<'a, A>where
&'a TestClient<A>: RefUnwindSafe,
impl<'a, A> Send for TestRequest<'a, A>where
&'a TestClient<A>: Send,
impl<'a, A> Sync for TestRequest<'a, A>where
&'a TestClient<A>: Sync,
impl<'a, A> Unpin for TestRequest<'a, A>where
&'a TestClient<A>: Unpin,
impl<'a, A> UnsafeUnpin for TestRequest<'a, A>where
&'a TestClient<A>: UnsafeUnpin,
impl<'a, A> UnwindSafe for TestRequest<'a, A>where
&'a TestClient<A>: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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