umbral-testing 0.0.1

Test helpers for umbral apps: TestClient, temp pools, response assertions, and model factories (factory_boy-style).
Documentation

umbral-testing — test helpers for umbral apps.

Django's TestCase + Client ergonomics, in the Rust shape. The repeated work in every plugin's tests/integration.rs was four things: spin up a fresh sqlite pool, build the router, send requests, read the response. This crate collapses those into:

  • [TempPool] — a tempfile-backed SQLite pool that's dropped when the guard goes out of scope.
  • [TestClient] — wraps an [axum::Router] with HTTP-verb- shaped methods, a per-client cookie jar (so a session set on one request rides on the next), and JSON helpers.
  • [TestResponse] — owns the response bytes and headers and exposes assertion helpers (assert_status, body_json, assert_body_contains).

This crate is NOT a plugin. It's a sibling utility library consumed by test code — drop umbral-testing into a crate's [dev-dependencies] and you don't carry it into release builds.

use umbral_testing::{TempPool, TestClient};

#[tokio::test]
async fn list_endpoint_returns_seeded_rows() {
    let pool = TempPool::new().await;
    // ... build router using pool.handle() ...
    let client = TestClient::new(router);
    let resp = client.get("/api/notes").await;
    resp.assert_status_ok();
    let notes: Vec<Note> = resp.body_json();
    assert_eq!(notes.len(), 2);
}