Skip to content

Commit

Permalink
fix: change output for RPUSH to return length
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-Chowdhary committed Oct 5, 2024
1 parent b909f8d commit a801211
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions integration_tests/commands/async/deque_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ func TestRPush(t *testing.T) {
{
name: "RPUSH",
cmds: []string{"RPUSH k v", "RPUSH k v1 1 v2 2", "RPUSH k 3 3 3 v3 v3 v3"},
expect: []any{"OK", "OK", "OK"},
expect: []any{int64(1), int64(5), int64(11)},
},
{
name: "RPUSH normal values",
cmds: []string{"RPUSH k " + strings.Join(deqNormalValues, " ")},
expect: []any{"OK"},
expect: []any{int64(25)},
},
{
name: "RPUSH edge values",
cmds: []string{"RPUSH k " + strings.Join(deqEdgeValues, " ")},
expect: []any{"OK"},
expect: []any{int64(42)},
},
}

Expand Down Expand Up @@ -284,17 +284,17 @@ func TestRPushLPop(t *testing.T) {
{
name: "RPUSH LPOP",
cmds: []string{"RPUSH k v1 1", "LPOP k", "LPOP k", "LPOP k"},
expect: []any{"OK", "v1", "1", "(nil)"},
expect: []any{int64(2), "v1", "1", "(nil)"},
},
{
name: "RPUSH LPOP normal values",
cmds: append([]string{"RPUSH k " + strings.Join(deqNormalValues, " ")}, getPops(deqNormalValues)...),
expect: append(append([]any{"OK"}, getPopExpects(deqNormalValues)...), "(nil)"),
expect: append(append([]any{int64(14)}, getPopExpects(deqNormalValues)...), "(nil)"),
},
{
name: "RPUSH LPOP edge values",
cmds: append([]string{"RPUSH k " + strings.Join(deqEdgeValues, " ")}, getPops(deqEdgeValues)...),
expect: append(append([]any{"OK"}, getPopExpects(deqEdgeValues)...), "(nil)"),
expect: append(append([]any{int64(17)}, getPopExpects(deqEdgeValues)...), "(nil)"),
},
}

Expand Down Expand Up @@ -338,17 +338,17 @@ func TestRPushRPop(t *testing.T) {
{
name: "RPUSH RPOP",
cmds: []string{"RPUSH k v1 1", "RPOP k", "RPOP k", "RPOP k"},
expect: []any{"OK", "1", "v1", "(nil)"},
expect: []any{int64(2), "1", "v1", "(nil)"},
},
{
name: "RPUSH RPOP normal values",
cmds: append([]string{"RPUSH k " + strings.Join(deqNormalValues, " ")}, getPops(deqNormalValues)...),
expect: append(append([]any{"OK"}, getPopExpects(deqNormalValues)...), "(nil)"),
expect: append(append([]any{int64(14)}, getPopExpects(deqNormalValues)...), "(nil)"),
},
{
name: "RPUSH RPOP edge values",
cmds: append([]string{"RPUSH k " + strings.Join(deqEdgeValues, " ")}, getPops(deqEdgeValues)...),
expect: append(append([]any{"OK"}, getPopExpects(deqEdgeValues)...), "(nil)"),
expect: append(append([]any{int64(17)}, getPopExpects(deqEdgeValues)...), "(nil)"),
},
}

Expand Down Expand Up @@ -383,7 +383,7 @@ func TestLRPushLRPop(t *testing.T) {
"RPOP k", "LPOP k", "LPOP k", "RPOP k",
},
expect: []any{
"OK", int64(4),
int64(2), int64(4),
"1000", "v1000", "2000",
int64(2),
"v2000", "v6", "(nil)", "(nil)",
Expand Down Expand Up @@ -422,7 +422,7 @@ func TestLLEN(t *testing.T) {
"RPOP k", "LLEN k", "LPOP k", "LPOP k", "RPOP k", "LLEN k",
},
expect: []any{
"OK", int64(4), int64(4),
int64(2), int64(4), int64(4),
"1000", int64(3), "v1000", "2000", int64(1),
int64(2), int64(2),
"v2000", int64(1), "v6", "(nil)", "(nil)", int64(0),
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -3434,7 +3434,7 @@ func evalRPUSH(args []string, store *dstore.Store) []byte {
obj.Value.(*Deque).RPush(args[i])
}

return clientio.RespOK
return clientio.Encode((obj.Value.(*Deque).Length), false)
}

func evalRPOP(args []string, store *dstore.Store) []byte {
Expand Down

0 comments on commit a801211

Please sign in to comment.