2 个版本
0.1.1 | 2022年12月1日 |
---|---|
0.1.0 | 2022年11月30日 |
#2190 在 开发工具
8KB
120 行
sqlx-db-ssk-tester
这是一个测试 sqlx 与 postgres 的工具,目前仅支持 tokio 运行时。
由 tyr Chen 研究
如何使用
您应该在测试中首先创建一个 TestDb
数据结构。它将自动为您创建数据库和连接池。然后您可以从它获取连接字符串或连接池,在您的代码中使用。当 TestDb
被丢弃时,它将自动删除数据库。
#[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
}
享受这个 crate 带来的乐趣!
许可证
本项目根据 MIT 许可证分发。
有关详细信息,请参阅 LICENSE。
版权所有 2021 ssk
依赖关系
~19–30MB
~560K SLoC