#[warm_test]Expand description
Wraps an async test function so it receives a freshly cloned, migrated
sqlx::PgPool cloned from a template that’s built once.
The test database is dropped after the function returns, whether it panics or succeeds.
The template is built once per unique migration set, and reused across every test and every run,
so tests run in milliseconds regardless of schema size.
ⓘ
#[warmpool::warm_test(migrations = "./migrations")]
async fn creates_a_post(pool: sqlx::PgPool) {
let row: (i64,) = sqlx::query_as("SELECT count(*) FROM posts")
.fetch_one(&pool)
.await
.unwrap();
assert_eq!(row.0, 0);
}Arguments all optional:
migrations = "./path"defaults to./migrations.database_url_env = "ENV_VAR"defaults toDATABASE_URL.clone_strategy = "wal_log" | "file_copy" | "auto"— defaults to whatever [warmpool::TemplatePoolBuilder] defaults to (wal_logas of warmpool 0.1.1+). Rejected at compile time if it isn’t one of those three strings.