Skip to content

Commit

Permalink
fix tests and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolysergeev committed Feb 12, 2023
1 parent dd77a80 commit 10d3577
Show file tree
Hide file tree
Showing 3 changed files with 237 additions and 240 deletions.
26 changes: 12 additions & 14 deletions redis/src/main/scala/zio/redis/Input.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object Input {

case object AggregateInput extends Input[Aggregate] {
def encode(data: Aggregate)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Literal("AGGREGATE"), RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal("AGGREGATE"), RespArgument.Literal(data.stringify))
}

case object AlphaInput extends Input[Alpha] {
Expand All @@ -58,7 +58,7 @@ object Input {

case object AuthInput extends Input[Auth] {
def encode(data: Auth)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Literal("AUTH"), RespArgument.Unknown(data.password))
RespCommand(RespArgument.Literal("AUTH"), RespArgument.Value(data.password))
}

case object BoolInput extends Input[Boolean] {
Expand Down Expand Up @@ -88,7 +88,7 @@ object Input {

val respArgs = data match {
case BitFieldGet(t, o) =>
Chunk(RespArgument.Unknown("GET"), RespArgument.Unknown(t.stringify), RespArgument.Unknown(o.toString))
Chunk(RespArgument.Literal("GET"), RespArgument.Unknown(t.stringify), RespArgument.Unknown(o.toString))
case BitFieldSet(t, o, v) =>
Chunk(
RespArgument.Literal("SET"),
Expand Down Expand Up @@ -150,7 +150,7 @@ object Input {

case object ClientPauseModeInput extends Input[ClientPauseMode] {
def encode(data: ClientPauseMode)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object ClientTrackingInput
Expand Down Expand Up @@ -257,7 +257,7 @@ object Input {

case object KeepTtlInput extends Input[KeepTtl] {
def encode(data: KeepTtl)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object LimitInput extends Input[Limit] {
Expand Down Expand Up @@ -310,7 +310,7 @@ object Input {

case object ReplaceInput extends Input[Replace] {
def encode(data: Replace)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object StoreDistInput extends Input[StoreDist] {
Expand Down Expand Up @@ -599,7 +599,6 @@ object Input {
RespCommand(RespArgument.Key(key), RespArgument.Literal("EX")) ++ DurationSecondsInput.encode(duration)
case (key, Expire.SetExpireMilliseconds, duration) =>
RespCommand(RespArgument.Key(key), RespArgument.Literal("PX")) ++ DurationMillisecondsInput.encode(duration)
case (key, _, _) => RespCommand(RespArgument.Key(key))
}
}

Expand All @@ -610,7 +609,6 @@ object Input {
RespCommand(RespArgument.Key(key), RespArgument.Literal("EXAT")) ++ TimeSecondsInput.encode(instant)
case (key, ExpiredAt.SetExpireAtMilliseconds, instant) =>
RespCommand(RespArgument.Key(key), RespArgument.Literal("PXAT")) ++ TimeMillisecondsInput.encode(instant)
case (key, _, _) => RespCommand(RespArgument.Key(key))
}
}

Expand Down Expand Up @@ -651,32 +649,32 @@ object Input {

case object WithScoresInput extends Input[WithScores] {
def encode(data: WithScores)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object WithCoordInput extends Input[WithCoord] {
def encode(data: WithCoord)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object WithDistInput extends Input[WithDist] {
def encode(data: WithDist)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object WithHashInput extends Input[WithHash] {
def encode(data: WithHash)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object WithForceInput extends Input[WithForce] {
def encode(data: WithForce)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object WithJustIdInput extends Input[WithJustId] {
def encode(data: WithJustId)(implicit codec: BinaryCodec): RespCommand =
RespCommand(RespArgument.Unknown(data.stringify))
RespCommand(RespArgument.Literal(data.stringify))
}

case object YesNoInput extends Input[Boolean] {
Expand Down
4 changes: 2 additions & 2 deletions redis/src/main/scala/zio/redis/RespValue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import zio.redis.RespValue.BulkString
import zio.schema.Schema
import zio.schema.codec.BinaryCodec

final class RespCommand(val respArgs: Chunk[RespArgument]) {
final case class RespCommand(respArgs: Chunk[RespArgument]) {
def ++(that: RespCommand): RespCommand = RespCommand(this.respArgs ++ that.respArgs)

def transformArgs(f: RespArgument => RespArgument): RespCommand = RespCommand(respArgs.map(f(_)))
Expand Down Expand Up @@ -54,7 +54,7 @@ object RespArgument {
}

object Unknown {
def apply(str: String): Unknown = Unknown(Chunk.fromArray(str.getBytes(StandardCharsets.UTF_8)))
def apply(str: String): Unknown = Unknown(Chunk.fromArray(str.getBytes(StandardCharsets.UTF_8)))
def apply[A](data: A)(implicit codec: BinaryCodec, schema: Schema[A]): Key = Key(codec.encode(schema)(data))
}

Expand Down
Loading

0 comments on commit 10d3577

Please sign in to comment.