sqlx-pg-test-template

Crates.iosqlx-pg-test-template
lib.rssqlx-pg-test-template
version0.1.2
created_at2024-12-10 19:28:18.63207+00
updated_at2024-12-12 17:20:42.37861+00
descriptionFaster version of #[sqlx-test] macro for PostgreSQL
homepagehttps://github.com/gzigzigzeo/sqlx-pg-test-template
repositoryhttps://github.com/gzigzigzeo/sqlx-pg-test-template
max_upload_size
id1478966
size8,676
Victor Sokolov (gzigzigzeo)

documentation

README

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.

Commit count: 18

cargo fmt