pub struct TestApp { /* private fields */ }Implementations§
Source§impl TestApp
impl TestApp
Sourcepub fn override_dep<T: Send + Sync + 'static>(self, value: T) -> Self
pub fn override_dep<T: Send + Sync + 'static>(self, value: T) -> Self
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: Serialize>( &self, path: &str, body: &B, ) -> TestResponse
pub async fn put_json<B: Serialize>(&self, path: &str, body: &B) -> TestResponse
pub async fn patch_json<B: Serialize>( &self, path: &str, body: &B, ) -> TestResponse
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: Serialize>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponse
pub async fn post_json_with<B: Serialize>( &self, path: &str, body: &B, headers: &[(&str, &str)], ) -> TestResponse
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: Serialize>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponse
pub async fn put_json_with<B: Serialize>( &self, path: &str, body: &B, headers: &[(&str, &str)], ) -> TestResponse
PUT JSON with explicit request headers.
Sourcepub async fn patch_json_with<B: Serialize>(
&self,
path: &str,
body: &B,
headers: &[(&str, &str)],
) -> TestResponse
pub async fn patch_json_with<B: Serialize>( &self, path: &str, body: &B, headers: &[(&str, &str)], ) -> TestResponse
PATCH JSON with explicit request headers.