1 unstable release

0.1.0 Dec 14, 2022

#2231 in Development tools

Download history 3/week @ 2024-02-22 1/week @ 2024-02-29 47/week @ 2024-03-21 14/week @ 2024-03-28 4/week @ 2024-04-04

65 downloads per month

MIT license

8KB
106 lines

sqlx-db-tester

This a tool to test sqlx with postgres. It only supports tokio runtime at this moment.

How to use it

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_awesom_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
}

Have fun with this crate!

License

This project is distributed under the terms of MIT.

See LICENSE for details.

Dependencies

~20–33MB
~650K SLoC