Skip to content

Commit 467f52b

Browse files
committed
test/sync_wrapper: Explicitly start and enter runtime to fix sqlite test variant
1 parent d1e2e9e commit 467f52b

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
@@ -4,6 +4,17 @@ use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
44

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

0 commit comments

Comments
 (0)