File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
crates/crates_io_test_db/src Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,12 @@ use diesel::sql_query;
55use diesel_migrations:: { FileBasedMigrations , MigrationHarness } ;
66use once_cell:: sync:: Lazy ;
77use rand:: Rng ;
8+ use std:: time:: Duration ;
89use tracing:: { debug, instrument} ;
910use url:: Url ;
1011
12+ const CONNECTION_TIMEOUT : Duration = Duration :: from_secs ( 5 ) ;
13+
1114struct TemplateDatabase {
1215 base_url : Url ,
1316 pool : Pool < ConnectionManager < PgConnection > > ,
@@ -33,6 +36,7 @@ impl TemplateDatabase {
3336 // contention, so this is using a connection pool to reduce unnecessary
3437 // waiting times for the tests.
3538 let pool = Pool :: builder ( )
39+ . connection_timeout ( CONNECTION_TIMEOUT )
3640 . max_size ( 10 )
3741 . min_idle ( Some ( 0 ) )
3842 . build_unchecked ( ConnectionManager :: new ( base_url. as_ref ( ) ) ) ;
@@ -104,6 +108,7 @@ impl TestDatabase {
104108 url. set_path ( & format ! ( "/{name}" ) ) ;
105109
106110 let pool = Pool :: builder ( )
111+ . connection_timeout ( CONNECTION_TIMEOUT )
107112 . min_idle ( Some ( 0 ) )
108113 . build_unchecked ( ConnectionManager :: new ( url. as_ref ( ) ) ) ;
109114
You can’t perform that action at this time.
0 commit comments