Skip to main content

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//! - [`ResponseAssert`] / [`assert_json_snapshot`] — uniform response checks
6//!
7//! **Apps:** prefer `sova = { features = ["testing"] }` — the facade re-exports this crate.
8//! **Plugins:** depend on `sova-testing` / `sova-core` directly (avoid the facade).
9//!
10//! Auth helpers (`acting_as`, user factories) live in [`sova_auth::testing`].
11//! Notification `acting_as_id` lives in [`sova_notifications::testing`].
12//!
13//! ```ignore
14//! use sova::{ResponseAssert, TestApp, TestClient, assert_json_snapshot};
15//! use sova_notifications::testing::ActingAs;
16//!
17//! let (_db, app) = TestApp::builder()
18//!     .migrator::<NotificationsMigrator>()
19//!     .install(Notifications::new().mount("/notifications"))
20//!     .build()
21//!     .await;
22//! let c = TestClient::tracked(app).await.unwrap();
23//! c.acting_as_id(1);
24//! let res = c.get("/notifications").await;
25//! res.assert_status(200);
26//! assert_json_snapshot!("inbox", res.json_value());
27//! ```
28
29mod app;
30mod assert;
31mod sqlite;
32
33pub use app::{TestApp, TestAppBuilder};
34pub use assert::with_json_redactions;
35pub use sova_core::ResponseAssert;
36pub use sqlite::{apply_migrations, SqliteTestDb};
37
38/// Re-export so [`assert_json_snapshot`] can resolve `$crate::insta` from dependents.
39pub use insta;