Skip to main content

TestApp

Struct TestApp 

Source
pub struct TestApp { /* private fields */ }

Implementations§

Source§

impl TestApp

Source

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.

Source

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.

Source

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.

Source

pub async fn get(&self, path: &str) -> TestResponse

Source

pub async fn delete(&self, path: &str) -> TestResponse

Source

pub async fn post_json<B: Serialize>( &self, path: &str, body: &B, ) -> TestResponse

Source

pub async fn put_json<B: Serialize>(&self, path: &str, body: &B) -> TestResponse

Source

pub async fn patch_json<B: Serialize>( &self, path: &str, body: &B, ) -> TestResponse

Source

pub async fn options_with( &self, path: &str, headers: &[(&str, &str)], ) -> TestResponse

A CORS preflight (OPTIONS) request with headers.

Source

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.

Source

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.

Source

pub async fn post_bytes_with( &self, path: &str, bytes: &[u8], headers: &[(&str, &str)], ) -> TestResponse

POST a raw byte body with explicit request headers.

Source

pub async fn post_multipart( &self, path: &str, parts: &[TestPart], ) -> TestResponse

POSTs a multipart/form-data request assembled from parts.

Source

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).

Source

pub async fn get_with( &self, path: &str, headers: &[(&str, &str)], ) -> TestResponse

GET with explicit request headers (auth tests, content negotiation).

Source

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).

Source

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.

Source

pub async fn post_json_with<B: Serialize>( &self, path: &str, body: &B, headers: &[(&str, &str)], ) -> TestResponse

POST JSON with explicit request headers.

Source

pub async fn delete_with( &self, path: &str, headers: &[(&str, &str)], ) -> TestResponse

DELETE with explicit request headers (guarded-route auth tests).

Source

pub async fn put_json_with<B: Serialize>( &self, path: &str, body: &B, headers: &[(&str, &str)], ) -> TestResponse

PUT JSON with explicit request headers.

Source

pub async fn patch_json_with<B: Serialize>( &self, path: &str, body: &B, headers: &[(&str, &str)], ) -> TestResponse

PATCH JSON with explicit request headers.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.