diff --git a/cmd_geo.go b/cmd_geo.go index 29a92d5..6702e96 100644 --- a/cmd_geo.go +++ b/cmd_geo.go @@ -594,7 +594,7 @@ func withinRadius(members []ssElem, longitude, latitude, radius float64) []geoDi } func parseUnit(u string) float64 { - switch u { + switch strings.ToLower(u) { case "m": return 1 case "km": diff --git a/cmd_geo_test.go b/cmd_geo_test.go index 6d09c0d..d3ffd85 100644 --- a/cmd_geo_test.go +++ b/cmd_geo_test.go @@ -288,7 +288,7 @@ func TestGeodist(t *testing.T) { ) mustDo(t, c, "GEODIST", "Sicily", "Palermo", "Catania", "miles", - proto.Error("ERR unsupported unit provided. please use m, km, ft, mi"), + proto.Error("ERR unsupported unit provided. please use M, KM, FT, MI"), ) mustDo(t, c, "GEODIST", "Sicily", "Palermo", "Catania", "m", "too many", diff --git a/integration/geo_test.go b/integration/geo_test.go index 4ce87dd..ca8b863 100644 --- a/integration/geo_test.go +++ b/integration/geo_test.go @@ -103,6 +103,7 @@ func TestGeodist(t *testing.T) { c.Do("GEODIST", "nosuch", "Catania", "Palermo") c.DoRounded(2, "GEODIST", "Sicily", "Palermo", "Catania", "m") c.Do("GEODIST", "Sicily", "Palermo", "Catania", "km") + c.Do("GEODIST", "Sicily", "Palermo", "Catania", "KM") c.Do("GEODIST", "Sicily", "Palermo", "Catania", "mi") c.DoRounded(2, "GEODIST", "Sicily", "Palermo", "Catania", "ft") c.Do("GEODIST", "Sicily", "Palermo", "Palermo") @@ -112,6 +113,7 @@ func TestGeodist(t *testing.T) { c.Error("wrong number", "GEODIST", "Sicily") c.Error("wrong number", "GEODIST", "Sicily", "Palermo") c.Error("syntax error", "GEODIST", "Sicily", "Palermo", "Palermo", "miles", "too many") + c.Error("unsupported unit provided. please use M, KM, FT, MI", "GEODIST", "Sicily", "Palermo", "Catania", "foobar") c.Do("SET", "string", "123") c.Error("wrong kind", "GEODIST", "string", "a", "b") }) @@ -128,6 +130,7 @@ func TestGeoradius(t *testing.T) { "-73.98384899986625", "40.76172799961419", "50th St", ) c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "km") + c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "KM") c.Do("GEORADIUS", "stations", "1.0", "1.0", "1", "km") c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "ft", "WITHDIST") c.Do("GEORADIUS", "stations", "-73.9718893", "40.7728773", "4", "m", "WITHDIST") diff --git a/redis.go b/redis.go index 2ccec39..5a21fe7 100644 --- a/redis.go +++ b/redis.go @@ -45,7 +45,7 @@ const ( msgStreamIDTooSmall = "ERR The ID specified in XADD is equal or smaller than the target stream top item" msgStreamIDZero = "ERR The ID specified in XADD must be greater than 0-0" msgNoScriptFound = "NOSCRIPT No matching script. Please use EVAL." - msgUnsupportedUnit = "ERR unsupported unit provided. please use m, km, ft, mi" + msgUnsupportedUnit = "ERR unsupported unit provided. please use M, KM, FT, MI" msgXreadUnbalanced = "ERR Unbalanced 'xread' list of streams: for each stream key an ID or '$' must be specified." msgXgroupKeyNotFound = "ERR The XGROUP subcommand requires the key to exist. Note that for CREATE you may want to use the MKSTREAM option to create an empty stream automatically." msgXtrimInvalidStrategy = "ERR unsupported XTRIM strategy. Please use MAXLEN, MINID"