Skip to content

Commit 7396c56

Browse files
committed
Let the test suite setup the database
1 parent 8b713b1 commit 7396c56

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
@@ -567,12 +567,24 @@ impl KvStore for PostgresBackendImpl {
567567
mod tests {
568568
use crate::postgres_store::PostgresBackendImpl;
569569
use api::define_kv_store_tests;
570+
use tokio::sync::OnceCell;
570571

571-
define_kv_store_tests!(
572-
PostgresKvStoreTest,
573-
PostgresBackendImpl,
572+
static START: OnceCell<()> = OnceCell::const_new();
573+
574+
define_kv_store_tests!(PostgresKvStoreTest, PostgresBackendImpl, {
575+
START
576+
.get_or_init(|| async {
577+
// Initialize the database once, and have other threads wait
578+
PostgresBackendImpl::new(
579+
"postgresql://postgres:postgres@localhost:5432",
580+
"postgres",
581+
)
582+
.await
583+
.unwrap();
584+
})
585+
.await;
574586
PostgresBackendImpl::new("postgresql://postgres:postgres@localhost:5432", "postgres")
575587
.await
576588
.unwrap()
577-
);
589+
});
578590
}

0 commit comments

Comments
 (0)