-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
In one project I am working on we are using sea-orm migrations to setup our db, and sqlx::test for unit tests. It would be nice if there was some way to execute them before sqlx::test runs the actual test, while still being able to use fixtures.
As supporting sea_orm and any other kind of orm inside sqlx would be pretty unreasonable,
the simplest solution I could come up with is basically to add a pre-migrate or post-migrate hook to sqlx::test:
async fn some_init_fn(conn: PgConn) -> () {
// Do some initializing
}
#[sqlx::test(
migrations = false,
pre_migrate = some_init_fn,
path = "../fixtures",
scripts(some_fixture)
)]
async fn test(db: PgPool) {
// test something
}
Alternatively I would probably create some kind of other "test" crate which makes this possible, but that would require doing the same work already done here all over again.
I think this would be a pretty simple addition to implement. If that is welcome, I can create a pr for it as well, just want to have some kind of indication for that so that I don't waste my time on it :)