Skip to content

Commit

Permalink
add test case for atomic pipeline (redis-rs#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
CNLHC authored and nonirosenfeldredis committed Feb 13, 2023
1 parent f10c016 commit 280eaed
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions redis-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,27 @@ mod tests {
.expect("success");
assert_eq!(results, vec!["hello", "world"]);
}

#[test]
fn pipeline_atomic_test() {
let mut conn = MockRedisConnection::new(vec![MockCmd::with_values(
pipe().atomic().cmd("GET").arg("foo").cmd("GET").arg("bar"),
Ok(vec![Value::Bulk(
vec!["hello", "world"]
.into_iter()
.map(|x| Value::Data(x.as_bytes().into()))
.collect(),
)]),
)]);

let results: Vec<String> = pipe()
.atomic()
.cmd("GET")
.arg("foo")
.cmd("GET")
.arg("bar")
.query(&mut conn)
.expect("success");
assert_eq!(results, vec!["hello", "world"]);
}
}

0 comments on commit 280eaed

Please sign in to comment.