tests are robusts running in parallel

This commit is contained in:
filipriec
2025-06-18 22:38:00 +02:00
parent 4843b0778c
commit e25213ed1b
4 changed files with 65 additions and 37 deletions

View File

@@ -1,5 +1,7 @@
// tests/table_definition/post_table_definition_test.rs
use crate::common::setup_test_db;
use crate::common::setup_isolated_db;
use common::proto::multieko2::table_definition::{
ColumnDefinition, PostTableDefinitionRequest, TableLink,
};
@@ -10,9 +12,13 @@ use tonic::Code;
// ========= Fixtures =========
/// THIS IS THE KEY CHANGE.
/// The `pool` fixture, which most of your tests already use,
/// will now provide a completely isolated database schema for every test.
#[fixture]
async fn pool() -> PgPool {
setup_test_db().await
// Instead of the old setup, we call the new isolated setup.
setup_isolated_db().await
}
#[fixture]
@@ -22,8 +28,8 @@ async fn closed_pool(#[future] pool: PgPool) -> PgPool {
pool
}
/// A fixture that creates a pre-existing 'customers' table definition,
/// so we can test linking to it.
/// This fixture now works perfectly and is also isolated,
/// because it depends on the `pool` fixture above. No changes needed here!
#[fixture]
async fn pool_with_preexisting_table(#[future] pool: PgPool) -> PgPool {
let pool = pool.await;
@@ -43,6 +49,7 @@ async fn pool_with_preexisting_table(#[future] pool: PgPool) -> PgPool {
pool
}
// ========= Helper Functions =========
/// Checks the PostgreSQL information_schema to verify a table and its columns exist.