Skip to content

Commit

Permalink
Adding test code for zset (OpenAtomFoundation#2087)
Browse files Browse the repository at this point in the history
* test: geo list zset

* change geo
  • Loading branch information
dingxiaoshuai123 authored Oct 31, 2023
1 parent d796dd7 commit 02f5197
Show file tree
Hide file tree
Showing 4 changed files with 2,184 additions and 964 deletions.
17 changes: 8 additions & 9 deletions tests/integration/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ var _ = Describe("Geo Commands", func() {
Expect(geoAdd.Val()).To(Equal(int64(0)))
})

//It("should search geo radius", func() {
// res, err := client.GeoRadius(ctx, "Sicily", 15, 37, &redis.GeoRadiusQuery{
// Radius: 200,
// }).Result()
// Expect(err).NotTo(HaveOccurred())
// Expect(res).To(HaveLen(2))
// Expect(res[0].Name).To(Equal("Palermo"))
// Expect(res[1].Name).To(Equal("Catania"))
//})
It("should search geo radius", func() {
res := client.Do(ctx, "GEORADIUS", "Sicily", 15, 37, 200, "km", "WITHDIST", "WITHCOORD")
Expect(res.Err()).NotTo(HaveOccurred())
Expect(res.Val()).To(HaveLen(2))

Expect(res.Val()).To(Equal([]interface{}{[]interface{}{"Palermo", "190.4424", []interface{}{"13.361389338970184", "38.115556395496299"}}, []interface{}{"Catania", "56.4413", []interface{}{"15.087267458438873", "37.50266842333162"}}}))

})

It("should geo radius and store the result", func() {
n, err := client.GeoRadiusStore(ctx, "Sicily", 15, 37, &redis.GeoRadiusQuery{
Expand Down
64 changes: 32 additions & 32 deletions tests/integration/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,22 +374,22 @@ var _ = Describe("List Commands", func() {
})

// todo fix: https://github.com/OpenAtomFoundation/pika/issues/1791
//It("should LPop", func() {
// rPush := client.RPush(ctx, "list", "one")
// Expect(rPush.Err()).NotTo(HaveOccurred())
// rPush = client.RPush(ctx, "list", "two")
// Expect(rPush.Err()).NotTo(HaveOccurred())
// rPush = client.RPush(ctx, "list", "three")
// Expect(rPush.Err()).NotTo(HaveOccurred())
//
// lPop := client.LPop(ctx, "list")
// Expect(lPop.Err()).NotTo(HaveOccurred())
// Expect(lPop.Val()).To(Equal("one"))
//
// lRange := client.LRange(ctx, "list", 0, -1)
// Expect(lRange.Err()).NotTo(HaveOccurred())
// Expect(lRange.Val()).To(Equal([]string{"two", "three"}))
//})
It("should LPop", func() {
rPush := client.RPush(ctx, "list", "one")
Expect(rPush.Err()).NotTo(HaveOccurred())
rPush = client.RPush(ctx, "list", "two")
Expect(rPush.Err()).NotTo(HaveOccurred())
rPush = client.RPush(ctx, "list", "three")
Expect(rPush.Err()).NotTo(HaveOccurred())

lPop := client.LPop(ctx, "list")
Expect(lPop.Err()).NotTo(HaveOccurred())
Expect(lPop.Val()).To(Equal("one"))

lRange := client.LRange(ctx, "list", 0, -1)
Expect(lRange.Err()).NotTo(HaveOccurred())
Expect(lRange.Val()).To(Equal([]string{"two", "three"}))
})

It("should LPopCount", func() {
rPush := client.RPush(ctx, "list11", "one")
Expand Down Expand Up @@ -593,22 +593,22 @@ var _ = Describe("List Commands", func() {
})

// todo fix: https://github.com/OpenAtomFoundation/pika/issues/1791
//It("should RPop", func() {
// rPush := client.RPush(ctx, "list", "one")
// Expect(rPush.Err()).NotTo(HaveOccurred())
// rPush = client.RPush(ctx, "list", "two")
// Expect(rPush.Err()).NotTo(HaveOccurred())
// rPush = client.RPush(ctx, "list", "three")
// Expect(rPush.Err()).NotTo(HaveOccurred())
//
// rPop := client.RPop(ctx, "list")
// Expect(rPop.Err()).NotTo(HaveOccurred())
// Expect(rPop.Val()).To(Equal("three"))
//
// lRange := client.LRange(ctx, "list", 0, -1)
// Expect(lRange.Err()).NotTo(HaveOccurred())
// Expect(lRange.Val()).To(Equal([]string{"one", "two"}))
//})
It("should RPop", func() {
rPush := client.RPush(ctx, "list", "one")
Expect(rPush.Err()).NotTo(HaveOccurred())
rPush = client.RPush(ctx, "list", "two")
Expect(rPush.Err()).NotTo(HaveOccurred())
rPush = client.RPush(ctx, "list", "three")
Expect(rPush.Err()).NotTo(HaveOccurred())

rPop := client.RPop(ctx, "list")
Expect(rPop.Err()).NotTo(HaveOccurred())
Expect(rPop.Val()).To(Equal("three"))

lRange := client.LRange(ctx, "list", 0, -1)
Expect(lRange.Err()).NotTo(HaveOccurred())
Expect(lRange.Val()).To(Equal([]string{"one", "two"}))
})

It("should RPopCount", func() {
rPush := client.RPush(ctx, "list", "one", "two", "three", "four")
Expand Down
Loading

0 comments on commit 02f5197

Please sign in to comment.