From 14bdf886d515df2cea19f7bd6e852ecc449dcb6a Mon Sep 17 00:00:00 2001 From: git-hulk Date: Wed, 23 Nov 2022 21:35:58 +0800 Subject: [PATCH] Fix the script load should return SHA as the bulk string --- src/commands/redis_cmd.cc | 2 +- tests/gocase/unit/scripting/scripting_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands/redis_cmd.cc b/src/commands/redis_cmd.cc index 81d2fb8fd59..a0dee16d1f1 100644 --- a/src/commands/redis_cmd.cc +++ b/src/commands/redis_cmd.cc @@ -5033,7 +5033,7 @@ class CommandScript : public Commander { if (!s.IsOK()) { return s; } - *output = Redis::SimpleString(sha); + *output = Redis::BulkString(sha); } else { return Status(Status::NotOK, "Unknown SCRIPT subcommand or wrong # of args"); } diff --git a/tests/gocase/unit/scripting/scripting_test.go b/tests/gocase/unit/scripting/scripting_test.go index 90e774e4f04..984f6cbd3ae 100644 --- a/tests/gocase/unit/scripting/scripting_test.go +++ b/tests/gocase/unit/scripting/scripting_test.go @@ -366,6 +366,14 @@ assert(bit.bor(1,2,4,8,16,32,64,128) == 255) require.Equal(t, []bool{true, false}, r2.Val()) }) + t.Run("SCRIPT LOAD - should return SHA as the bulk string", func(t *testing.T) { + c := srv.NewTCPClient() + defer func() { require.NoError(t, c.Close()) }() + require.NoError(t, c.WriteArgs("script", "load", "return 'bulk string'")) + c.MustRead(t, "$40") + c.MustRead(t, "04b85c6fe6dbd424de3fb5914509afa7597570f2") + }) + t.Run("SCRIPT LOAD - is able to register scripts in the scripting cache", func(t *testing.T) { r1 := rdb.ScriptLoad(ctx, "return 'loaded'") require.NoError(t, r1.Err())