Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for Sync trait on Pool::get() #334

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion postgres/tests/postgres.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, env, time::Duration};
use std::{collections::HashMap, env, pin::Pin, time::Duration};

use futures::future;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -212,6 +212,27 @@ async fn statement_caches_clear() {
assert!(client1.statement_cache.size() == 0);
}

#[tokio::test]
async fn sync_trait_get() {
let pool = create_pool();

type ClosureFuture = Pin<Box<dyn std::future::Future<Output = ()> + Send + Sync>>;
async fn test_closure<T: Fn(String) -> ClosureFuture + Send + Sync + 'static>(_: T) {
return;
}

test_closure(move |_| Box::pin(async move {})).await;
assert!(true);

test_closure(move |_| {
let pool = pool.clone();
Box::pin(async move {
pool.get().await;
})
});
assert!(true);
}

struct Env {
backup: HashMap<String, Option<String>>,
}
Expand Down
Loading