mirror of
https://github.com/redis/go-redis.git
synced 2025-06-14 01:21:30 +03:00
127
commands_test.go
127
commands_test.go
@ -4392,6 +4392,133 @@ var _ = Describe("Commands", func() {
|
||||
}))
|
||||
})
|
||||
|
||||
It("should XINFO STREAM FULL", func() {
|
||||
res, err := client.XInfoStreamFull(ctx, "stream", 2).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
res.RadixTreeKeys = 0
|
||||
res.RadixTreeNodes = 0
|
||||
|
||||
// Verify DeliveryTime
|
||||
now := time.Now()
|
||||
maxElapsed := 10 * time.Minute
|
||||
for k, g := range res.Groups {
|
||||
for k2, p := range g.Pending {
|
||||
Expect(now.Sub(p.DeliveryTime)).To(BeNumerically("<=", maxElapsed))
|
||||
res.Groups[k].Pending[k2].DeliveryTime = time.Time{}
|
||||
}
|
||||
for k3, c := range g.Consumers {
|
||||
Expect(now.Sub(c.SeenTime)).To(BeNumerically("<=", maxElapsed))
|
||||
res.Groups[k].Consumers[k3].SeenTime = time.Time{}
|
||||
|
||||
for k4, p := range c.Pending {
|
||||
Expect(now.Sub(p.DeliveryTime)).To(BeNumerically("<=", maxElapsed))
|
||||
res.Groups[k].Consumers[k3].Pending[k4].DeliveryTime = time.Time{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Expect(res).To(Equal(&redis.XInfoStreamFull{
|
||||
Length: 3,
|
||||
RadixTreeKeys: 0,
|
||||
RadixTreeNodes: 0,
|
||||
LastGeneratedID: "3-0",
|
||||
Entries: []redis.XMessage{
|
||||
{ID: "1-0", Values: map[string]interface{}{"uno": "un"}},
|
||||
{ID: "2-0", Values: map[string]interface{}{"dos": "deux"}},
|
||||
},
|
||||
Groups: []redis.XInfoStreamGroup{
|
||||
{
|
||||
Name: "group1",
|
||||
LastDeliveredID: "3-0",
|
||||
PelCount: 3,
|
||||
Pending: []redis.XInfoStreamGroupPending{
|
||||
{
|
||||
ID: "1-0",
|
||||
Consumer: "consumer1",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
{
|
||||
ID: "2-0",
|
||||
Consumer: "consumer1",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
},
|
||||
Consumers: []redis.XInfoStreamConsumer{
|
||||
{
|
||||
Name: "consumer1",
|
||||
SeenTime: time.Time{},
|
||||
PelCount: 2,
|
||||
Pending: []redis.XInfoStreamConsumerPending{
|
||||
{
|
||||
ID: "1-0",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
{
|
||||
ID: "2-0",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "consumer2",
|
||||
SeenTime: time.Time{},
|
||||
PelCount: 1,
|
||||
Pending: []redis.XInfoStreamConsumerPending{
|
||||
{
|
||||
ID: "3-0",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "group2",
|
||||
LastDeliveredID: "3-0",
|
||||
PelCount: 2,
|
||||
Pending: []redis.XInfoStreamGroupPending{
|
||||
{
|
||||
ID: "2-0",
|
||||
Consumer: "consumer1",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
{
|
||||
ID: "3-0",
|
||||
Consumer: "consumer1",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
},
|
||||
Consumers: []redis.XInfoStreamConsumer{
|
||||
{
|
||||
Name: "consumer1",
|
||||
SeenTime: time.Time{},
|
||||
PelCount: 2,
|
||||
Pending: []redis.XInfoStreamConsumerPending{
|
||||
{
|
||||
ID: "2-0",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
{
|
||||
ID: "3-0",
|
||||
DeliveryTime: time.Time{},
|
||||
DeliveryCount: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
It("should XINFO GROUPS", func() {
|
||||
res, err := client.XInfoGroups(ctx, "stream").Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
Reference in New Issue
Block a user