Skip to content

Commit

Permalink
added blocking commands tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avifenesh committed Jul 3, 2024
1 parent 4571c91 commit 20a2863
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions redis/tests/test_blocking_commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![cfg(feature = "cluster-async")]
mod support;

#[cfg(test)]
mod test_blocking_commands {
use redis::AsyncCommands;

use crate::support::*;
#[tokio::test]
async fn test_blocking_command_when_cluster_drops() {
let mut cluster = TestClusterContext::new(3, 0);
let mut connection = cluster.async_connection(None).await;
let time_now = std::time::SystemTime::now();
futures::future::join(
async {
let res = connection.blpop::<&str, f64>("foo", 0.0).await;
assert!(res.is_err());
println!("blpop returned error {:?}", res.map_err(|e| e.to_string()));
println!("time elapsed: {:?}", time_now.elapsed().unwrap());
},
async {
tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
drop(cluster);
},
)
.await;
cluster = TestClusterContext::new(3, 0);
connection = cluster.async_connection(None).await;
let res: () = connection.set("foo", "bar").await.unwrap();
assert!(res == ());
}
}

0 comments on commit 20a2863

Please sign in to comment.