Skip to content

Commit

Permalink
fix auth cmd response
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnu-liguobin committed Feb 26, 2021
1 parent 6231147 commit 3902571
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions redis/src/main/scala/zio/redis/TestExecutor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -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))(
Expand Down

0 comments on commit 3902571

Please sign in to comment.