pub struct TestApp {
pub app: Application,
pub container: Arc<Container>,
}Expand description
Test application for integration testing
Fields§
§app: Application§container: Arc<Container>Implementations§
Source§impl TestApp
impl TestApp
Sourcepub fn new(container: Container, router: Router) -> Self
pub fn new(container: Container, router: Router) -> Self
Create a new test application
armature_core::Container clones share the same underlying
(Arc-backed) storage, so cloning the caller-supplied container into
Application::new — rather than handing the Application a brand
new, empty Container::new() — keeps self.container and the
container the running Application resolves against in sync:
anything registered through either handle is visible through both.
Sourcepub fn get<T: Provider + Clone + 'static>(&self) -> Option<T>
pub fn get<T: Provider + Clone + 'static>(&self) -> Option<T>
Get a service from the container.
Delegates to the stored armature_core::Container. Returns None
if no provider of type T was registered (via TestAppBuilder,
add_module, or directly on the container).
Sourcepub fn client(&self) -> TestClient
pub fn client(&self) -> TestClient
Create a test client for making requests
§Examples
use armature_testing::TestAppBuilder;
use armature_core::HttpResponse;
let app = TestAppBuilder::new()
.with_route("/test", |_req| async {
Ok(HttpResponse::ok().with_body(b"OK".to_vec()))
})
.build();
let client = app.client();
let response = client.get("/test").await;
assert_eq!(response.status(), Some(200));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
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
impl<R, D> DepsPresent<D> for R
Source§impl<T> Injectable for T
impl<T> Injectable for T
Source§fn type_id_of() -> TypeIdwhere
Self: Sized,
fn type_id_of() -> TypeIdwhere
Self: Sized,
Returns the TypeId of this type (for internal use)
Source§fn type_name_of() -> &'static strwhere
Self: Sized,
fn type_name_of() -> &'static strwhere
Self: Sized,
Returns the type name for debugging