暴露redis EvalSha 以及ScriptLoad接口 (#538)

Co-authored-by: shanehe <shanehe@zego.im>
This commit is contained in:
hexiaoen
2021-03-03 17:09:27 +08:00
committed by GitHub
parent a25cba5380
commit b321622c95
2 changed files with 29 additions and 3 deletions

View File

@@ -947,13 +947,24 @@ func TestRedisString(t *testing.T) {
func TestRedisScriptLoad(t *testing.T) {
runOnRedis(t, func(client *Redis) {
client.Ping()
_, err := NewRedis(client.Addr, "").scriptLoad("foo")
_, err := NewRedis(client.Addr, "").ScriptLoad("foo")
assert.NotNil(t, err)
_, err = client.scriptLoad("foo")
_, err = client.ScriptLoad("foo")
assert.NotNil(t, err)
})
}
func TestRedisEvalSha(t *testing.T) {
runOnRedis(t, func(client *Redis) {
client.Ping()
scriptHash, err := client.ScriptLoad(`return redis.call("EXISTS", KEYS[1])`)
assert.Nil(t, err)
result, err := client.EvalSha(scriptHash, []string{"key1"})
assert.Nil(t, err)
assert.Equal(t, int64(0), result)
})
}
func TestRedisToPairs(t *testing.T) {
pairs := toPairs([]red.Z{
{