1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-15 12:41:41 +03:00
This commit is contained in:
ofekshenawa
2025-05-07 17:00:05 +03:00
parent edb6283eb5
commit fc7939534f

View File

@ -6772,6 +6772,36 @@ var _ = Describe("Commands", func() {
}))
})
It("should return -1 for nil lag in XINFO GROUPS", func() {
_, err := client.XAdd(ctx, &redis.XAddArgs{Stream: "s", ID: "0-1", Values: []string{"foo", "1"}}).Result()
Expect(err).NotTo(HaveOccurred())
client.XAdd(ctx, &redis.XAddArgs{Stream: "s", ID: "0-2", Values: []string{"foo", "2"}})
Expect(err).NotTo(HaveOccurred())
client.XAdd(ctx, &redis.XAddArgs{Stream: "s", ID: "0-3", Values: []string{"foo", "3"}})
Expect(err).NotTo(HaveOccurred())
err = client.XGroupCreate(ctx, "s", "g", "0").Err()
Expect(err).NotTo(HaveOccurred())
err = client.XReadGroup(ctx, &redis.XReadGroupArgs{Group: "g", Consumer: "c", Streams: []string{"s", ">"}, Count: 1, Block: -1, NoAck: false}).Err()
Expect(err).NotTo(HaveOccurred())
client.XDel(ctx, "s", "0-2")
res, err := client.XInfoGroups(ctx, "s").Result()
Expect(err).NotTo(HaveOccurred())
Expect(res).To(Equal([]redis.XInfoGroup{
{
Name: "g",
Consumers: 1,
Pending: 1,
LastDeliveredID: "0-1",
EntriesRead: 1,
Lag: -1, // nil lag from Redis is reported as -1
},
}))
})
It("should XINFO CONSUMERS", func() {
res, err := client.XInfoConsumers(ctx, "stream", "group1").Result()
Expect(err).NotTo(HaveOccurred())