Skip to content

Commit

Permalink
Fix MEMORY subcommand casing (#389)
Browse files Browse the repository at this point in the history
compare case in-sensitive
  • Loading branch information
joshaber authored Dec 10, 2024
1 parent 1863d22 commit ef93126
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func (m *Miniredis) cmdMemory(c *server.Peer, cmd string, args []string) {
withTx(m, c, func(c *server.Peer, ctx *connCtx) {
db := m.db(ctx.selectedDB)

cmd, args := args[0], args[1:]
cmd, args := strings.ToLower(args[0]), args[1:]
switch cmd {
case "USAGE":
case "usage":
if len(args) < 1 {
setDirty(c)
c.WriteError(errWrongNumber("memory|usage"))
Expand Down
10 changes: 10 additions & 0 deletions cmd_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,13 @@ func TestCmdServerMemoryUsage(t *testing.T) {
proto.Int(124), // normally, with Redis it should be 56 but we don't have the same overhead as Redis
)
}

func TestCmdServerMemoryUsageLowerCase(t *testing.T) {
_, c := runWithClient(t)

c.Do("SET", "foo", "bar")
mustDo(t, c,
"memory", "usage", "foo",
proto.Int(19),
)
}

0 comments on commit ef93126

Please sign in to comment.