Skip to content

Commit

Permalink
[fix] make Pipeline handle returned bulks correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
framlog authored and nihohit committed Feb 28, 2024
1 parent 78a37b5 commit 3867f3f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion redis/src/aio/multiplexed_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ where
match result {
Ok(item) => {
entry.buffer = Some(match entry.buffer.take() {
Some(Value::Bulk(mut values)) => {
Some(Value::Bulk(mut values)) if entry.current_response_count > 1 => {
values.push(item);
Value::Bulk(values)
}
Expand Down
19 changes: 18 additions & 1 deletion redis/tests/test_async.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures::{prelude::*, StreamExt};
use redis::{
aio::{ConnectionLike, MultiplexedConnection},
cmd, AsyncCommands, ErrorKind, RedisResult,
cmd, pipe, AsyncCommands, ErrorKind, RedisResult,
};

use crate::support::*;
Expand Down Expand Up @@ -181,6 +181,23 @@ fn test_error(con: &MultiplexedConnection) -> impl Future<Output = RedisResult<(
}
}

#[test]
fn test_pipe_over_multiplexed_connection() {
let ctx = TestContext::new();
block_on_all(async move {
let mut con = ctx.multiplexed_async_connection().await?;
let mut pipe = pipe();
pipe.zrange("zset", 0, 0);
pipe.zrange("zset", 0, 0);
let frames = con.send_packed_commands(&pipe, 0, 2).await?;
assert_eq!(frames.len(), 2);
assert!(matches!(frames[0], redis::Value::Bulk(_)));
assert!(matches!(frames[1], redis::Value::Bulk(_)));
RedisResult::Ok(())
})
.unwrap();
}

#[test]
fn test_args_multiplexed_connection() {
let ctx = TestContext::new();
Expand Down

0 comments on commit 3867f3f

Please sign in to comment.