Crates.io | sqlx-postgres-tester |
lib.rs | sqlx-postgres-tester |
version | 0.1.1 |
source | src |
created_at | 2023-01-05 05:37:49.231924 |
updated_at | 2023-01-05 10:31:51.672571 |
description | A simple tool to test postgres with sqlx and tokio. It will automatically create a database and drop it after test. |
homepage | https://github.com/lshoo/sqlx-postgres-tester |
repository | https://github.com/lshoo/ |
max_upload_size | |
id | 751317 |
size | 20,053 |
This is a tool to test sqlx with postgres and tokio runtime only.
First, create a TestDb
struct instance in tests. It will automatically create database and a connection pool.
Then get the connection string or connection pool from it to use in codes.
Finally, when TestDb
gets dropped, it will automatically drop the database.
#[tokio::test]
async fn test_db_should_work() {
let tdb = TestPg::default();
let pool = tdb.get_pool().await;
// do something with pool
}
This project is distributed under the terms of MIT.
See LICENSE for details.
Copyright 2023 lshoo