2 个版本
0.1.1 | 2023年1月5日 |
---|---|
0.1.0 | 2023年1月5日 |
#2445 in 开发工具
8KB
105 行
sqlx-postgres-tester
这是一个仅用于测试 sqlx 与 postgres 和 tokio 运行时的工具。
如何使用
首先,在测试中创建一个 TestDb
结构体实例。它将自动创建数据库和连接池。然后从它获取连接字符串或连接池,用于代码中。最后,当 TestDb
被丢弃时,它将自动删除数据库。
#[tokio::test]
async fn test_db_should_work() {
let tdb = TestPg::default();
let pool = tdb.get_pool().await;
// do something with pool
}
许可证
该项目根据 MIT 许可证分发。
有关详细信息,请参阅 LICENSE。
版权所有 2023 lshoo
依赖关系
~18–31MB
~551K SLoC