Skip to main content

TestApp

Struct TestApp 

Source
pub struct TestApp<'app> { /* private fields */ }
Expand description

An in-memory borrowed HTTP adapter over the shared executable operation graph.

Implementations§

Source§

impl<'app> TestApp<'app>

Source

pub fn new(app: &'app ExecutableApp) -> Self

Source

pub const fn with_max_body_bytes(self, max_body_bytes: usize) -> Self

Source

pub const fn with_unverified_security_schemes(self, allow: bool) -> Self

Allows operations that declare a security scheme to run without a registered verifier. Defaults to false.

Passing true disables the fail-closed guard, so an in-memory test can exercise a secured operation without registering a verifier.

Source

pub async fn startup(&self) -> Result<(), DependencyError>

Runs application startup hooks for an in-memory test lifespan.

§Errors

Returns the first startup failure.

Source

pub async fn shutdown(&self) -> Result<(), DependencyError>

Runs application shutdown hooks for an in-memory test lifespan.

§Errors

Returns the first cleanup failure after all shutdown hooks have run.

Source

pub fn with_openapi(self, config: OpenApiConfig) -> Self

Mounts precompiled OpenAPI JSON and UI assets in the in-memory adapter.

Source

pub fn with_middleware(self, middleware: impl HttpMiddleware + 'static) -> Self

Registers runtime-neutral HTTP middleware for every request.

Source

pub fn with_shared_middleware(self, middleware: Rc<dyn HttpMiddleware>) -> Self

Registers shared middleware state for every request.

Source

pub fn with_scoped_middleware( self, scope: MiddlewareScope, middleware: impl HttpMiddleware + 'static, ) -> Self

Registers runtime-neutral HTTP middleware for one path prefix or operation selection.

Source

pub fn with_shared_scoped_middleware( self, scope: MiddlewareScope, middleware: Rc<dyn HttpMiddleware>, ) -> Self

Registers shared middleware state for one path prefix or operation selection.

Source

pub fn with_error_handler( self, handler: impl HttpErrorHandler + 'static, ) -> Self

Registers an application-level handler for failure responses.

Source

pub fn with_shared_error_handler( self, handler: Rc<dyn HttpErrorHandler>, ) -> Self

Registers shared application-level error handler state.

Source

pub async fn call(&self, request: Request) -> Response

Source

pub async fn call_controlled( &self, request: Request, control: InvocationControl, ) -> Response

Auto Trait Implementations§

§

impl<'app> !RefUnwindSafe for TestApp<'app>

§

impl<'app> !Send for TestApp<'app>

§

impl<'app> !Sync for TestApp<'app>

§

impl<'app> !UnwindSafe for TestApp<'app>

§

impl<'app> Freeze for TestApp<'app>

§

impl<'app> Unpin for TestApp<'app>

§

impl<'app> UnsafeUnpin for TestApp<'app>

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> BackgroundExt for T

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<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> ResponseExt for T

Source§

fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> WithHeaders<Self>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.