Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:4.0.2 changelog && add some test #2977

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions tests/integration/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,8 @@ var _ = Describe("List Commands", func() {
Expect(lpush.Val()).To(Equal(int64(4)))

getRes, err := client.Get(ctx, "list1").Result()
Expect(err).To(HaveOccurred()) // An error is expected since listkey is a list, not a string
Expect(getRes).To(Equal(""))
Expect(err).To(HaveOccurred()) // An error is expected since listkey is a list, not a string
Expect(getRes).To(Equal(""))

lrang := client.LRange(ctx, "list1", 0, -1)
Expect(lrang.Err()).NotTo(HaveOccurred())
Expand All @@ -1314,5 +1314,42 @@ var _ = Describe("List Commands", func() {
Expect(lrang.Val()).To(Equal([]string{"4", "3", "2", "1", "5"}))

})

It("should LPUSH and LRANGE", func() {
// LPUSH 操作
rPush := client.LPush(ctx, "mylist", "a", "b", "c", "d", "e")
Expect(rPush.Err()).NotTo(HaveOccurred())
Expect(rPush.Val()).To(Equal(int64(5)))

// LRANGE 验证列表内容
lRange := client.LRange(ctx, "mylist", 0, -1)
Expect(lRange.Err()).NotTo(HaveOccurred())
Expect(lRange.Val()).To(Equal([]string{"e", "d", "c", "b", "a"}))
})

It("should RPOPLPUSH and update list order", func() {
// 初始化列表
client.LPush(ctx, "mylist", "a", "b", "c", "d", "e")

// 第一次 RPOPLPUSH 操作
rPopPush := client.RPopLPush(ctx, "mylist", "mylist")
Expect(rPopPush.Err()).NotTo(HaveOccurred())
Expect(rPopPush.Val()).To(Equal("a"))

// 验证列表内容
lRange := client.LRange(ctx, "mylist", 0, -1)
Expect(lRange.Err()).NotTo(HaveOccurred())
Expect(lRange.Val()).To(Equal([]string{"a", "e", "d", "c", "b"}))

// 第二次 RPOPLPUSH 操作
rPopPush = client.RPopLPush(ctx, "mylist", "mylist")
Expect(rPopPush.Err()).NotTo(HaveOccurred())
Expect(rPopPush.Val()).To(Equal("b"))

// 验证列表内容
lRange = client.LRange(ctx, "mylist", 0, -1)
Expect(lRange.Err()).NotTo(HaveOccurred())
Expect(lRange.Val()).To(Equal([]string{"b", "a", "e", "d", "c"}))
})
})
})
Loading