1
0
mirror of https://github.com/redis/go-redis.git synced 2025-06-14 01:21:30 +03:00

Add writing version of GeoRadius commands

This commit is contained in:
Vladimir Mihailenco
2019-08-09 15:04:56 +03:00
parent 40a478a654
commit 191391d66d
3 changed files with 81 additions and 15 deletions

View File

@ -3733,6 +3733,46 @@ var _ = Describe("Commands", func() {
Expect(res[1].Name).To(Equal("Catania"))
})
It("should geo radius and store the result", func() {
n, err := client.GeoRadiusStore("Sicily", 15, 37, &redis.GeoRadiusQuery{
Radius: 200,
Store: "result",
}).Result()
Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(2)))
res, err := client.ZRangeWithScores("result", 0, -1).Result()
Expect(err).NotTo(HaveOccurred())
Expect(res).To(ContainElement(redis.Z{
Score: 3.479099956230698e+15,
Member: "Palermo",
}))
Expect(res).To(ContainElement(redis.Z{
Score: 3.479447370796909e+15,
Member: "Catania",
}))
})
It("should geo radius and store dist", func() {
n, err := client.GeoRadiusStore("Sicily", 15, 37, &redis.GeoRadiusQuery{
Radius: 200,
StoreDist: "result",
}).Result()
Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(2)))
res, err := client.ZRangeWithScores("result", 0, -1).Result()
Expect(err).NotTo(HaveOccurred())
Expect(res).To(ContainElement(redis.Z{
Score: 190.44242984775784,
Member: "Palermo",
}))
Expect(res).To(ContainElement(redis.Z{
Score: 56.4412578701582,
Member: "Catania",
}))
})
It("should search geo radius with options", func() {
res, err := client.GeoRadius("Sicily", 15, 37, &redis.GeoRadiusQuery{
Radius: 200,