File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -573,12 +573,24 @@ impl KvStore for PostgresBackendImpl {
573573mod 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}
You can’t perform that action at this time.
0 commit comments