Update command.go

This commit is contained in:
hible 2023-05-05 20:40:51 +08:00
parent fcb3506e79
commit d5358ff27d
2 changed files with 9 additions and 5 deletions

View File

@ -1452,12 +1452,16 @@ func readXMessageSlice(rd *proto.Reader) ([]XMessage, error) {
return nil, err return nil, err
} }
msgs := make([]XMessage, n) msgs := make([]XMessage, 0, n)
for i := 0; i < len(msgs); i++ { for i := 0; i < n; i++ {
if msgs[i], err = readXMessage(rd); err != nil { if xMessage, err := readXMessage(rd); err == nil {
return nil, err msgs = append(msgs, xMessage)
} }
} }
if len(msgs) < 1 {
// Compatible with previous returns
return nil, proto.Nil
}
return msgs, nil return msgs, nil
} }

View File

@ -5691,7 +5691,7 @@ var _ = Describe("Commands", func() {
Stream: "stream", Stream: "stream",
Group: "group", Group: "group",
Consumer: "consumer", Consumer: "consumer",
Messages: []string{"1-0", "2-0", "3-0"}, Messages: []string{"???-???", "1-0", "2-0", "3-0"},
}).Result() }).Result()
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(msgs).To(Equal([]redis.XMessage{{ Expect(msgs).To(Equal([]redis.XMessage{{