Skip to content

Commit 1314607

Browse files
committed
Fixed tests after rebasing
1 parent 6b6081e commit 1314607

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

redis/tests/support/mock_cluster.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ impl MockConnectionBehavior {
5454
}
5555
}
5656

57+
pub fn add_new_mock_connection_behavior(name: &str, handler: Handler) {
58+
MOCK_CONN_BEHAVIORS
59+
.write()
60+
.unwrap()
61+
.insert(name.to_string(), MockConnectionBehavior::new(name, handler));
62+
}
63+
5764
pub fn modify_mock_connection_behavior(name: &str, func: impl FnOnce(&mut MockConnectionBehavior)) {
5865
func(
5966
MOCK_CONN_BEHAVIORS
@@ -433,10 +440,7 @@ impl MockEnv {
433440
.unwrap();
434441

435442
let id = id.to_string();
436-
MOCK_CONN_BEHAVIORS.write().unwrap().insert(
437-
id.clone(),
438-
MockConnectionBehavior::new(&id, Arc::new(move |cmd, port| handler(cmd, port))),
439-
);
443+
add_new_mock_connection_behavior(&id, Arc::new(move |cmd, port| handler(cmd, port)));
440444
let client = client_builder.build().unwrap();
441445
let connection = client.get_generic_connection().unwrap();
442446
#[cfg(feature = "cluster-async")]

redis/tests/test_cluster_async.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,13 +593,7 @@ fn test_cluster_async_cannot_connect_to_server_with_unknown_host_name() {
593593
};
594594
let client_builder = ClusterClient::builder(vec![&*format!("redis://{name}")]);
595595
let client = client_builder.build().unwrap();
596-
MOCK_CONN_UTILS.write().unwrap().insert(
597-
name.to_string(),
598-
MockConnectionUtils {
599-
handler: Some(Arc::new(handler)),
600-
..Default::default()
601-
},
602-
);
596+
add_new_mock_connection_behavior(name, Arc::new(handler));
603597
let connection = client.get_generic_connection::<MockConnection>();
604598
assert!(connection.is_err());
605599
let err = connection.err().unwrap();

0 commit comments

Comments
 (0)