From a801211d28b2556cbe50e08ef9c69e3d246b278e Mon Sep 17 00:00:00 2001 From: Aditya Chowdhary Date: Sun, 6 Oct 2024 03:54:14 +0530 Subject: [PATCH] fix: change output for RPUSH to return length --- .../commands/async/deque_test.go | 22 +++++++++---------- internal/eval/eval.go | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/integration_tests/commands/async/deque_test.go b/integration_tests/commands/async/deque_test.go index b1b079dc9..f7e5c8ecb 100644 --- a/integration_tests/commands/async/deque_test.go +++ b/integration_tests/commands/async/deque_test.go @@ -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)}, }, } @@ -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)"), }, } @@ -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)"), }, } @@ -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)", @@ -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), diff --git a/internal/eval/eval.go b/internal/eval/eval.go index 789dcc7d9..c12e60889 100644 --- a/internal/eval/eval.go +++ b/internal/eval/eval.go @@ -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 {