sova_testing/lib.rs
1//! Framework-style test harness for Sova.
2//!
3//! - [`SqliteTestDb`] — tempfile sqlite + migrate
4//! - [`TestApp`] — App bootstrap with Db + plugins
5//! - [`ActingAs`] — inject auth / notification user on [`TestClient`]
6//! - [`ResponseAssert`] / [`assert_json_snapshot`] — uniform response checks
7//!
8//! ```ignore
9//! use sova_testing::{ActingAs, ResponseAssert, TestApp, assert_json_snapshot};
10//!
11//! let (_db, app) = TestApp::builder()
12//! .migrator::<NotificationsMigrator>()
13//! .install(Notifications::new().mount("/notifications"))
14//! .build()
15//! .await;
16//! let c = TestClient::tracked(app).unwrap();
17//! c.acting_as_id(1);
18//! let res = c.get("/notifications").await;
19//! res.assert_status(200);
20//! assert_json_snapshot!("inbox", res.json_value());
21//! ```
22
23mod app;
24mod assert;
25mod sqlite;
26
27#[cfg(feature = "auth")]
28mod acting;
29#[cfg(feature = "auth")]
30mod factory;
31
32#[cfg(all(not(feature = "auth"), feature = "notifications"))]
33mod acting_id;
34
35pub use app::{TestApp, TestAppBuilder};
36pub use assert::with_json_redactions;
37pub use sova_core::ResponseAssert;
38pub use sqlite::{apply_migrations, SqliteTestDb};
39
40#[cfg(feature = "auth")]
41pub use acting::ActingAs;
42#[cfg(feature = "auth")]
43pub use factory::{ensure_permission, ensure_role, UserFactory};
44
45#[cfg(all(not(feature = "auth"), feature = "notifications"))]
46pub use acting_id::ActingAs;