Skip to content

Commit

Permalink
add test for Sync trait
Browse files Browse the repository at this point in the history
  • Loading branch information
samchouse committed Jun 17, 2024
1 parent 7b933c5 commit f8be5c5
Showing 1 changed file with 22 additions and 1 deletion.
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

0 comments on commit f8be5c5

Please sign in to comment.