Skip to content

Commit f42cdb1

Browse files
committed
Let the test suite setup the database
1 parent 633ebfa commit f42cdb1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

rust/impls/src/postgres_store.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,24 @@ impl KvStore for PostgresBackendImpl {
573573
mod tests {
574574
use crate::postgres_store::PostgresBackendImpl;
575575
use api::define_kv_store_tests;
576+
use tokio::sync::OnceCell;
576577

577-
define_kv_store_tests!(
578-
PostgresKvStoreTest,
579-
PostgresBackendImpl,
578+
static START: OnceCell<()> = OnceCell::const_new();
579+
580+
define_kv_store_tests!(PostgresKvStoreTest, PostgresBackendImpl, {
581+
START
582+
.get_or_init(|| async {
583+
// Initialize the database once, and have other threads wait
584+
PostgresBackendImpl::new(
585+
"postgresql://postgres:postgres@localhost:5432",
586+
"postgres",
587+
)
588+
.await
589+
.unwrap();
590+
})
591+
.await;
580592
PostgresBackendImpl::new("postgresql://postgres:postgres@localhost:5432", "postgres")
581593
.await
582594
.unwrap()
583-
);
595+
});
584596
}

0 commit comments

Comments
 (0)