Skip to content

Commit a123c80

Browse files
authored
Merge pull request #193 from Turbo87/wrapper-tests
CI: Run `async-connection-wrapper` feature tests too
2 parents 18da19a + db8f535 commit a123c80

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
run: cargo +${{ matrix.rust }} version
203203

204204
- name: Test diesel_async
205-
run: cargo +${{ matrix.rust }} test --manifest-path Cargo.toml --no-default-features --features "${{ matrix.backend }} deadpool bb8 mobc"
205+
run: cargo +${{ matrix.rust }} test --manifest-path Cargo.toml --no-default-features --features "${{ matrix.backend }} deadpool bb8 mobc async-connection-wrapper"
206206

207207
- name: Run examples (Postgres)
208208
if: matrix.backend == 'postgres'

src/async_connection_wrapper.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub trait BlockOn {
4343
///
4444
/// # Examples
4545
///
46-
/// ```rust
46+
/// ```rust,no_run
4747
/// # include!("doctest_setup.rs");
4848
/// use schema::users;
4949
/// use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
@@ -61,7 +61,7 @@ pub trait BlockOn {
6161
///
6262
/// If you are in the scope of an existing tokio runtime you need to use
6363
/// `tokio::task::spawn_blocking` to encapsulate the blocking tasks
64-
/// ```rust
64+
/// ```rust,no_run
6565
/// # include!("doctest_setup.rs");
6666
/// use schema::users;
6767
/// use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;

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)