@@ -9169,6 +9169,45 @@ func (suite *GlideTestSuite) TestGeoAdd_InvalidArgs() {
91699169 })
91709170}
91719171
9172+ func (suite * GlideTestSuite ) TestGeoHash () {
9173+ suite .runWithDefaultClients (func (client api.BaseClient ) {
9174+ key1 := uuid .New ().String ()
9175+ t := suite .T ()
9176+
9177+ // Add some locations to the geo index
9178+ membersToCoordinates := map [string ]options.GeospatialData {
9179+ "Palermo" : {Longitude : 13.361389 , Latitude : 38.115556 },
9180+ "Catania" : {Longitude : 15.087269 , Latitude : 37.502669 },
9181+ }
9182+
9183+ // Add the coordinates
9184+ result , err := client .GeoAdd (key1 , membersToCoordinates )
9185+ assert .NoError (t , err )
9186+ assert .Equal (t , int64 (2 ), result )
9187+
9188+ // Test getting geohash for multiple members
9189+ geoHashResults , err := client .GeoHash (key1 , []string {"Palermo" , "Catania" })
9190+ fmt .Println (geoHashResults )
9191+ assert .NoError (t , err )
9192+ assert .Equal (t , 2 , len (geoHashResults ))
9193+ assert .Equal (t , geoHashResults [0 ], "sqc8b49rny0" )
9194+ assert .Equal (t , geoHashResults [1 ], "sqdtr74hyu0" )
9195+
9196+ // Test getting geohash for empty members
9197+ geoHashResults , err = client .GeoHash (key1 , []string {})
9198+ assert .NoError (t , err )
9199+ assert .Equal (t , 0 , len (geoHashResults ))
9200+
9201+ // Test with wrong key type
9202+ wrongKey := "{testKey}:3-" + uuid .New ().String ()
9203+ _ , err = client .Set (wrongKey , "value" )
9204+ assert .NoError (t , err )
9205+ _ , err = client .GeoHash (wrongKey , []string {"Palermo" })
9206+ assert .Error (t , err )
9207+ assert .IsType (t , & errors.RequestError {}, err )
9208+ })
9209+ }
9210+
91729211func (suite * GlideTestSuite ) TestGetSet_SendLargeValues () {
91739212 suite .runWithDefaultClients (func (client api.BaseClient ) {
91749213 key := suite .GenerateLargeUuid ()
0 commit comments