Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MEMORY subcommand casing #389

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),
)
}