From a372475874066915d944d2c25cfee45e58aa92be Mon Sep 17 00:00:00 2001 From: Tom Dyas Date: Thu, 20 May 2021 15:42:58 -0700 Subject: [PATCH] add test for pipeline --- src/testing.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/testing.rs b/src/testing.rs index d54b0b1dc..d8028cbca 100644 --- a/src/testing.rs +++ b/src/testing.rs @@ -300,7 +300,7 @@ impl AioConnectionLike for MockRedisConnection { mod tests { use super::MockRedisConnection; use crate::testing::MockCmd; - use crate::{cmd, ErrorKind, Value}; + use crate::{cmd, pipe, ErrorKind, Value}; #[test] fn sync_basic_test() { @@ -386,4 +386,21 @@ mod tests { assert_eq!(err.kind(), ErrorKind::ClientError); assert!(err.detail().unwrap().contains("unexpected command")); } + + #[test] + fn pipeline_basic_test() { + let mut conn = MockRedisConnection::new(vec![MockCmd::with_values( + pipe().cmd("GET").arg("foo").cmd("GET").arg("bar"), + Ok(vec!["hello", "world"]), + )]); + + let results: Vec = pipe() + .cmd("GET") + .arg("foo") + .cmd("GET") + .arg("bar") + .query(&mut conn) + .expect("success"); + assert_eq!(results, vec!["hello", "world"]); + } }