Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
monkey92t authored May 19, 2021
1 parent 76393b5 commit 1393126
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
8 changes: 7 additions & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -1769,8 +1769,14 @@ func xStreamInfoParser(rd *proto.Reader, n int64) (interface{}, error) {
info.LastGeneratedID, err = rd.ReadString()
case "first-entry":
info.FirstEntry, err = readXMessage(rd)
if err == Nil {
err = nil
}
case "last-entry":
info.LastEntry, err = readXMessage(rd)
if err == Nil {
err = nil
}
default:
return nil, fmt.Errorf("redis: unexpected content %s "+
"in XINFO STREAM reply", key)
Expand Down Expand Up @@ -2034,7 +2040,7 @@ func readXInfoStreamConsumers(rd *proto.Reader) ([]XInfoStreamConsumer, error) {

c.Pending = make([]XInfoStreamConsumerPending, 0, pendingNumber)

for f := 0; f < pendingNumber; f++ {
for pn := 0; pn < pendingNumber; pn++ {
nn, err := rd.ReadArrayLen()
if err != nil {
return nil, err
Expand Down
20 changes: 20 additions & 0 deletions commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4390,6 +4390,26 @@ var _ = Describe("Commands", func() {
FirstEntry: redis.XMessage{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
LastEntry: redis.XMessage{ID: "3-0", Values: map[string]interface{}{"tres": "troix"}},
}))

// stream is empty
n, err := client.XDel(ctx, "stream", "1-0", "2-0", "3-0").Result()
Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(3)))

res, err = client.XInfoStream(ctx, "stream").Result()
Expect(err).NotTo(HaveOccurred())
res.RadixTreeKeys = 0
res.RadixTreeNodes = 0

Expect(res).To(Equal(&redis.XInfoStream{
Length: 0,
RadixTreeKeys: 0,
RadixTreeNodes: 0,
Groups: 2,
LastGeneratedID: "3-0",
FirstEntry: redis.XMessage{},
LastEntry: redis.XMessage{},
}))
})

It("should XINFO STREAM FULL", func() {
Expand Down

0 comments on commit 1393126

Please sign in to comment.