From 390257119d3e3b69368e0594bf4d61fbc91ab4a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=A6=E5=A2=83=E8=BF=B7=E7=A6=BB?= Date: Fri, 26 Feb 2021 17:39:58 +0800 Subject: [PATCH] fix auth cmd response --- .../main/scala/zio/redis/TestExecutor.scala | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/redis/src/main/scala/zio/redis/TestExecutor.scala b/redis/src/main/scala/zio/redis/TestExecutor.scala index 073e1636f..3f0abdafa 100644 --- a/redis/src/main/scala/zio/redis/TestExecutor.scala +++ b/redis/src/main/scala/zio/redis/TestExecutor.scala @@ -17,6 +17,8 @@ private[redis] final class TestExecutor private ( result <- runCommand(name.asString, command.tail).commit } yield result + def errResponse(cmd: String) = RespValue.bulkString(s"(error) ERR wrong number of arguments for '$cmd' command") + private[this] def runCommand(name: String, input: Chunk[RespValue.BulkString]): STM[RedisError, RespValue] = name match { case api.Connection.Ping.name => @@ -27,6 +29,24 @@ private[redis] final class TestExecutor private ( input.head } + case api.Connection.Auth.name => + STM.succeedNow { + if (input.isEmpty) errResponse(api.Connection.Auth.name) + else + RespValue.bulkString("OK") + } + case api.Connection.Echo.name => + STM.succeedNow { + if (input.isEmpty) errResponse(api.Connection.Echo.name) + else + input.head + } + case api.Connection.Select.name => + STM.succeedNow { + if (input.isEmpty) errResponse(api.Connection.Select.name) + else RespValue.bulkString("OK") + } + case api.Sets.SAdd.name => val key = input.head.asString STM.ifM(isSet(key))(