Skip to content

Commit

Permalink
fix nonexistent key case
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandy Harvie committed Jul 13, 2023
1 parent 237ad34 commit e2d0a2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ func (m *Miniredis) cmdSmismember(c *server.Peer, cmd string, args []string) {
db := m.db(ctx.selectedDB)

if !db.exists(key) {
c.WriteInt(0)
c.WriteLen(len(values))
for range values {
c.WriteInt(0)
}
return
}

Expand Down
1 change: 1 addition & 0 deletions cmd_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func TestSmismember(t *testing.T) {
s.SetAdd("s", "aap", "noot", "mies")

mustDo(t, c, "SMISMEMBER", "s", "aap", "nosuch", "mies", proto.Ints(1, 0, 1))
mustDo(t, c, "SMISMEMBER", "q", "aap", "nosuch", "mies", proto.Ints(0, 0, 0))

t.Run("errors", func(t *testing.T) {
mustOK(t, c, "SET", "str", "value")
Expand Down
2 changes: 1 addition & 1 deletion integration/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestSet(t *testing.T) {
c.DoSorted("SMEMBERS", "nosuch")
c.Do("SISMEMBER", "s", "aap")
c.Do("SISMEMBER", "s", "nosuch")
c.Do("SMISMEMBER", "q", "aap", "noot", "nosuch")
c.Do("SMISMEMBER", "s", "aap", "noot", "nosuch")

c.Do("SCARD", "nosuch")
c.Do("SISMEMBER", "nosuch", "nosuch")
Expand Down

0 comments on commit e2d0a2a

Please sign in to comment.