trying to do get request unit test to work with vipe out database

This commit is contained in:
filipriec
2025-02-24 21:28:51 +01:00
parent 7a98bcd72e
commit c612409808
3 changed files with 156 additions and 0 deletions

View File

@@ -28,3 +28,24 @@ pub async fn setup_test_db() -> PgPool {
pool
}
// Add this to tests/common/mod.rs
pub async fn clear_all_tables(pool: &PgPool) {
// Clear tables in the correct order to respect foreign key constraints
clear_uctovnictvo_table(pool).await;
clear_adresar_table(pool).await;
}
pub async fn clear_uctovnictvo_table(pool: &PgPool) {
sqlx::query!("DELETE FROM uctovnictvo")
.execute(pool)
.await
.expect("Failed to clear uctovnictvo table");
}
pub async fn clear_adresar_table(pool: &PgPool) {
sqlx::query!("DELETE FROM adresar")
.execute(pool)
.await
.expect("Failed to clear adresar table");
}