From 8b7922d185896d0df2436a92a278454e588139b7 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 22 Aug 2016 09:46:42 +0000 Subject: [PATCH] Add test for GeoPos. --- commands_test.go | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/commands_test.go b/commands_test.go index b4d0ff3b..ea33e1b8 100644 --- a/commands_test.go +++ b/commands_test.go @@ -2689,20 +2689,35 @@ var _ = Describe("Commands", func() { // "166274.15156960033" // GEODIST Sicily Palermo Catania km // "166.27415156960032" - geoDist := client.GeoDist("Sicily", "Palermo", "Catania", "km") - Expect(geoDist.Err()).NotTo(HaveOccurred()) - Expect(geoDist.Val()).To(BeNumerically("~", 166.27, 0.01)) + dist, err := client.GeoDist("Sicily", "Palermo", "Catania", "km").Result() + Expect(err).NotTo(HaveOccurred()) + Expect(dist).To(BeNumerically("~", 166.27, 0.01)) - geoDist = client.GeoDist("Sicily", "Palermo", "Catania", "m") - Expect(geoDist.Err()).NotTo(HaveOccurred()) - Expect(geoDist.Val()).To(BeNumerically("~", 166274.15, 0.01)) + dist, err = client.GeoDist("Sicily", "Palermo", "Catania", "m").Result() + Expect(err).NotTo(HaveOccurred()) + Expect(dist).To(BeNumerically("~", 166274.15, 0.01)) }) It("should get geo hash in string representation", func() { - res, err := client.GeoHash("Sicily", "Palermo", "Catania").Result() + hashes, err := client.GeoHash("Sicily", "Palermo", "Catania").Result() Expect(err).NotTo(HaveOccurred()) - Expect(res[0]).To(Equal("sqc8b49rny0")) - Expect(res[1]).To(Equal("sqdtr74hyu0")) + Expect(hashes).To(ConsistOf([]string{"sqc8b49rny0", "sqdtr74hyu0"})) + }) + + It("should return geo position", func() { + pos, err := client.GeoPos("Sicily", "Palermo", "Catania", "NonExisting").Result() + Expect(err).NotTo(HaveOccurred()) + Expect(pos).To(ConsistOf([]*redis.GeoPos{ + { + Longitude: 13.361389338970184, + Latitude: 38.1155563954963, + }, + { + Longitude: 15.087267458438873, + Latitude: 37.50266842333162, + }, + nil, + })) }) })