Crates.io | sqlx-pg-test-template |
lib.rs | sqlx-pg-test-template |
version | |
source | src |
created_at | 2024-12-10 19:28:18.63207 |
updated_at | 2024-12-12 17:20:42.37861 |
description | Faster version of #[sqlx-test] macro for PostgreSQL |
homepage | https://github.com/gzigzigzeo/sqlx-pg-test-template |
repository | https://github.com/gzigzigzeo/sqlx-pg-test-template |
max_upload_size | |
id | 1478966 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Faster version of the #[sqlx::test]
macro for PostgreSQL. Database for every test
is created using CREATE DATABASE ... WITH TEMPLATE ...
and dropped after test is finished.
use sqlx_pg_test_template::test;
#[sqlx_pg_test_template::test]
async fn test(pool: Postgres<Pool>) {
// Do work
}
#[sqlx_pg_test_template::test(template = "my_db_with_seeds")]
async fn test_with_seeds(pool: Postgres<Pool>) {
// Do work
}
#[sqlx_pg_test_template::test(max_connections=5)]
async fn test_with_cursor(pool: Postgres<Pool>) {
// Do work
}
Run tests:
DATABASE_URL="postgres://postgres:postgres@localhost:5432/test_template" cargo test
Check documentation for details.