Skip to main content

Crate sova_testing

Crate sova_testing 

Source
Expand description

Framework-style test harness for Sova.

Auth helpers (acting_as, user factories) live in [sova_auth::testing]. Notification acting_as_id lives in [sova_notifications::testing].

use sova_testing::{ResponseAssert, TestApp, assert_json_snapshot};
use sova_notifications::testing::ActingAs;

let (_db, app) = TestApp::builder()
    .migrator::<NotificationsMigrator>()
    .install(Notifications::new().mount("/notifications"))
    .build()
    .await;
let c = TestClient::tracked(app).await.unwrap();
c.acting_as_id(1);
let res = c.get("/notifications").await;
res.assert_status(200);
assert_json_snapshot!("inbox", res.json_value());

Macros§

assert_json_snapshot
Assert JSON snapshot with common redactions (id, timestamps).

Structs§

SqliteTestDb
Isolated sqlite file + URL. Keeps TempDir alive for the test duration.
TestApp
Fluent bootstrap: migrate sqlite, install Db + plugins, run_startup.
TestAppBuilder

Traits§

ResponseAssert
Fluent assertions for HTTP responses in tests.

Functions§

apply_migrations
Run each migration’s up (for tests). Prefer unique [MigrationName]s so MigratorTrait::up / migrate CLI also work on composed migrators.
with_json_redactions
Redact volatile fields commonly present in API JSON.