Skip to content

Commit 37871e0

Browse files
committed
test/sync_wrapper: Explicitly start and enter runtime to fix sqlite test variant
1 parent b38a74b commit 37871e0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/sync_wrapper.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
66
fn test_sync_wrapper() {
77
use diesel::RunQueryDsl;
88

9+
// The runtime is required for the `sqlite` implementation to be able to use
10+
// `spawn_blocking()`. This is not required for `postgres` or `mysql`.
11+
#[cfg(feature = "sqlite")]
12+
let rt = tokio::runtime::Builder::new_current_thread()
13+
.enable_io()
14+
.build()
15+
.unwrap();
16+
17+
#[cfg(feature = "sqlite")]
18+
let _guard = rt.enter();
19+
920
let db_url = std::env::var("DATABASE_URL").unwrap();
1021
let mut conn = AsyncConnectionWrapper::<crate::TestConnection>::establish(&db_url).unwrap();
1122

0 commit comments

Comments
 (0)