pub struct TestApp { /* private fields */ }Implementations§
Source§impl TestApp
impl TestApp
Sourcepub fn override_dep<T>(self, value: T) -> TestApp
pub fn override_dep<T>(self, value: T) -> TestApp
Replace the provider for T everywhere (values AND factories) for all
subsequent requests. Chainable.
Sourcepub fn clock(&self) -> Clock
pub fn clock(&self) -> Clock
The controllable Clock injected for this test. advance/set it to
move domain time (rate windows, schedules, expiry) under the app; the
change is visible to every subsequent request and task context.
Sourcepub fn task_context(&self) -> TaskContext
pub fn task_context(&self) -> TaskContext
A TaskContext for resolving app-level dependencies
outside a request, honoring any override_dep fakes set on this TestApp.
Only app-level dependencies (those registered with App::provide /
App::provide_dep) are resolvable; module-scoped providers are not in
scope here.
pub async fn get(&self, path: &str) -> TestResponse
pub async fn delete(&self, path: &str) -> TestResponse
pub async fn post_json<B>(&self, path: &str, body: &B) -> TestResponsewhere
B: Serialize,
pub async fn put_json<B>(&self, path: &str, body: &B) -> TestResponsewhere
B: Serialize,
pub async fn patch_json<B>(&self, path: &str, body: &B) -> TestResponsewhere
B: Serialize,
Sourcepub async fn options_with(
&self,
path: &str,
headers: &[(&str, &str)],
) -> TestResponse
pub async fn options_with( &self, path: &str, headers: &[(&str, &str)], ) -> TestResponse
A CORS preflight (OPTIONS) request with headers.
Sourcepub async fn request(
&self,
method: Method,
path: &str,
headers: &[(&str, &str)],
body: Option<&[u8]>,
) -> TestResponse
pub async fn request( &self, method: Method, path: &str, headers: &[(&str, &str)], body: Option<&[u8]>, ) -> TestResponse
A by-method request with headers and an optional body. The generic seam the
*_with helpers don’t cover (OPTIONS, HEAD, custom flows). No simulated
peer address — use request_from for the IP-partition rate-limit tier.
Sourcepub async fn post_bytes(&self, path: &str, bytes: &[u8]) -> TestResponse
pub async fn post_bytes(&self, path: &str, bytes: &[u8]) -> TestResponse
POST a raw byte body (content-type application/octet-stream). Routes
and per-route body limits apply exactly as they do over a socket.
Sourcepub async fn post_bytes_with(
&self,
path: &str,
bytes: &[u8],
headers: &[(&str, &str)],
) -> TestResponse
pub async fn post_bytes_with( &self, path: &str, bytes: &[u8], headers: &[(&str, &str)], ) -> TestResponse
POST a raw byte body with explicit request headers.
Sourcepub async fn post_multipart(
&self,
path: &str,
parts: &[TestPart],
) -> TestResponse
pub async fn post_multipart( &self, path: &str, parts: &[TestPart], ) -> TestResponse
POSTs a multipart/form-data request assembled from parts.
Sourcepub async fn post_multipart_with(
&self,
path: &str,
parts: &[TestPart],
headers: &[(&str, &str)],
) -> TestResponse
pub async fn post_multipart_with( &self, path: &str, parts: &[TestPart], headers: &[(&str, &str)], ) -> TestResponse
post_multipart with extra request headers (e.g. auth cookies).
Sourcepub async fn get_with(
&self,
path: &str,
headers: &[(&str, &str)],
) -> TestResponse
pub async fn get_with( &self, path: &str, headers: &[(&str, &str)], ) -> TestResponse
GET with explicit request headers (auth tests, content negotiation).
Sourcepub async fn get_from(&self, path: &str, peer: SocketAddr) -> TestResponse
pub async fn get_from(&self, path: &str, peer: SocketAddr) -> TestResponse
Like get, but also sets the simulated client socket address (for the
rate-limiter’s IP partition tier).
Sourcepub async fn request_from(
&self,
method: Method,
path: &str,
headers: &[(&str, &str)],
peer: SocketAddr,
) -> TestResponse
pub async fn request_from( &self, method: Method, path: &str, headers: &[(&str, &str)], peer: SocketAddr, ) -> TestResponse
A by-method request with headers AND a simulated peer address.
Sourcepub async fn post_json_with<B>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponsewhere
B: Serialize,
pub async fn post_json_with<B>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponsewhere
B: Serialize,
POST JSON with explicit request headers.
Sourcepub async fn delete_with(
&self,
path: &str,
headers: &[(&str, &str)],
) -> TestResponse
pub async fn delete_with( &self, path: &str, headers: &[(&str, &str)], ) -> TestResponse
DELETE with explicit request headers (guarded-route auth tests).
Sourcepub async fn put_json_with<B>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponsewhere
B: Serialize,
pub async fn put_json_with<B>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponsewhere
B: Serialize,
PUT JSON with explicit request headers.
Sourcepub async fn patch_json_with<B>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponsewhere
B: Serialize,
pub async fn patch_json_with<B>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponsewhere
B: Serialize,
PATCH JSON with explicit request headers.
Auto Trait Implementations§
impl !RefUnwindSafe for TestApp
impl !UnwindSafe for TestApp
impl Freeze for TestApp
impl Send for TestApp
impl Sync for TestApp
impl Unpin for TestApp
impl UnsafeUnpin for TestApp
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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>
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>
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