Skip to content

Commit

Permalink
add test for pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Dyas committed Jun 8, 2021
1 parent 045261f commit 726d6df
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/testing.rs
Expand Up @@ -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() {
Expand Down Expand Up @@ -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<String> = pipe()
.cmd("GET")
.arg("foo")
.cmd("GET")
.arg("bar")
.query(&mut conn)
.expect("success");
assert_eq!(results, vec!["hello", "world"]);
}
}

0 comments on commit 726d6df

Please sign in to comment.