3 releases

0.1.2 Dec 12, 2024
0.1.1 Dec 12, 2024
0.1.0 Dec 10, 2024

#5 in #pg-test

Download history 47/week @ 2025-05-24 35/week @ 2025-05-31 60/week @ 2025-06-07 45/week @ 2025-06-14 49/week @ 2025-06-21 59/week @ 2025-06-28 53/week @ 2025-07-05 21/week @ 2025-07-12 34/week @ 2025-07-19 23/week @ 2025-07-26 29/week @ 2025-08-02 24/week @ 2025-08-09 38/week @ 2025-08-16 59/week @ 2025-08-23 51/week @ 2025-08-30 40/week @ 2025-09-06

190 downloads per month
Used in sqlx-pg-test-template

MIT license

7KB
110 lines

sqlx_pg_test_template

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.

Usage

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.

Dependencies

~155–550KB
~13K SLoC