SQLx creates a separate database for each test annotated with #[sqlx::test], and sometimes our test suite fails because SQLx can't connect to the database. Ideally, we want as few tests as possible so we won't get database connection errors when running the tests.
One way to solve this would be merging similar tests into one test. Such as:
#[sqlx::test]
async fn test_insert_user(db: PgPool) { /* ... */ }
#[sqlx::test]
async fn test_insert_no_bio(db: PgPool) { /* ... */ }
#[sqlx::test]
async fn test_insert_same_id(db: PgPool) { /* ... */ }
// These three tests can be merged into one test
#[sqlx::test]
async fn test_insert_user(db: PgPool) { /* We test all of the insert scenarios here */ }
SQLx creates a separate database for each test annotated with
#[sqlx::test]
, and sometimes our test suite fails because SQLx can't connect to the database. Ideally, we want as few tests as possible so we won't get database connection errors when running the tests.One way to solve this would be merging similar tests into one test. Such as: