Crates.io | sqlx-db-tester-fb |
lib.rs | sqlx-db-tester-fb |
version | 0.1.0 |
source | src |
created_at | 2023-05-11 06:50:20.347576 |
updated_at | 2023-05-11 06:50:20.347576 |
description | Self use , A simple tool to test sqlx with postgres. It will automatically create a database and drop it after the test. |
homepage | https://github.com/Bear-V/sqlx-db-tester-fb |
repository | https://github.com/Bear-V/sqlx-db-tester-fb |
max_upload_size | |
id | 861861 |
size | 22,698 |
This a tool to test sqlx with postgres. It only supports tokio runtime at this moment.
You should first create a TestDb
data structure in your tests. It will automatically create a database and a connection pool for you. You could then get the connection string or connection pool from it to use in your own code. When TestDb
gets dropped, it will automatically drop the database.
#[tokio::test]
fn some_test() {
let tdb = TestDb::new("localhost", 5432, "postgres", "postgres", "./migrations");
let pool = tdb.get_pool().await;
// do something with the pool
// when tdb gets dropped, the database will be dropped
}
This project is distributed under the terms of MIT.
See LICENSE for details.
Copyright 2023 Fly Bear