1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! # modo::testing
//!
//! Test helpers for building and exercising modo applications in-process.
//!
//! **Requires feature `test-helpers`** — the only feature flag modo ships.
//! Enable it in your `Cargo.toml` dev-dependency:
//!
//! ```toml
//! [dev-dependencies]
//! modo = { package = "modo-rs", version = "0.8", features = ["test-helpers"] }
//! ```
//!
//! Integration test files that use these helpers should also guard their
//! entire contents:
//!
//! ```rust,ignore
//! #![cfg(feature = "test-helpers")]
//! ```
//!
//! Lightweight utilities for integration-testing axum-based handlers without
//! spinning up a real HTTP server. Everything runs in-process using Tower's
//! [`oneshot`](tower::ServiceExt::oneshot) transport.
//!
//! # Provides
//!
//! - [`TestApp`] / [`TestAppBuilder`] — assemble a test application with routes,
//! services, and middleware; send requests via HTTP-method helpers.
//! - [`TestDb`] — in-memory libsql database with chainable `exec` / `migrate`
//! setup; exposes a [`Database`](crate::db::Database) handle via [`db()`](TestDb::db).
//! - [`TestPool`] — in-memory [`DatabasePool`](crate::db::DatabasePool) with chainable
//! `exec` setup; both default and shard databases use `:memory:`.
//! - [`TestRequestBuilder`] — fluent builder for a single in-process HTTP request
//! with JSON, form, and raw-body support.
//! - [`TestResponse`] — captured response with status, header, and body accessors.
//! - [`TestSession`] — session infrastructure for integration tests: creates the
//! `authenticated_sessions` table (see [`TestSession::SCHEMA_SQL`] and
//! [`TestSession::INDEXES_SQL`]), signs cookies, and builds a
//! [`CookieSessionLayer`](crate::auth::session::CookieSessionLayer).
//!
//! # Quick start
//!
//! ```rust,no_run
//! # #[cfg(feature = "test-helpers")]
//! # async fn example() {
//! use modo::testing::{TestApp, TestDb};
//! use axum::routing::get;
//!
//! async fn hello() -> &'static str { "hello" }
//!
//! let app = TestApp::builder()
//! .route("/", get(hello))
//! .build();
//!
//! let res = app.get("/").send().await;
//! assert_eq!(res.status(), 200);
//! assert_eq!(res.text(), "hello");
//! # }
//! ```
pub use ;
pub use TestDb;
pub use TestPool;
pub use TestRequestBuilder;
pub use TestResponse;
pub use TestSession;