Skip to content

Commit

Permalink
fff
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Sep 13, 2023
1 parent 5c9137c commit 640f947
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/types/redis_geo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ rocksdb::Status Geo::Get(const Slice &user_key, const Slice &member, GeoPoint *g

auto iter = geo_points.find(member.ToString());
if (iter == geo_points.end()) {
return rocksdb::Status::NotFound();
return rocksdb::Status::InvalidArgument("could not decode requested zset member");
}
*geo_point = iter->second;
return rocksdb::Status::OK();
Expand Down
24 changes: 24 additions & 0 deletions tests/gocase/unit/geo/geo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ func TestGeo(t *testing.T) {
require.EqualValues(t, []interface{}([]interface{}{}), rdb.Do(ctx, "GEORADIUSBYMEMBER_RO", "points", "member", "1", "km").Val())
})

t.Run("GEORADIUSBYMEMBER against non existing member", func(t *testing.T) {
require.NoError(t, rdb.Do(ctx, "DEL", "src", "dst").Err())

require.NoError(t, rdb.Do(ctx, "GEOADD", "src", "10", "10", "Shenzhen").Err())
require.Error(t, rdb.Do(ctx, "GEORADIUSBYMEMBER", "src", "Shenzhen_2", 20, "M").Err())

require.NoError(t, rdb.Do(ctx, "GEOADD", "dst", "20", "20", "Guangzhou").Err())
require.Error(t, rdb.Do(ctx, "GEORADIUSBYMEMBER", "src", "Shenzhen_2", 20, "M", "STORE", "dst").Err())
// Verify command does not affect dst
require.EqualValues(t, 1, rdb.Exists(ctx, "dst").Val())
})

t.Run("GEORADIUSBYMEMBER store: remove the dst key when there is no result set", func(t *testing.T) {
require.NoError(t, rdb.Do(ctx, "DEL", "src", "dst").Err())

Expand Down Expand Up @@ -244,6 +256,18 @@ func TestGeo(t *testing.T) {
require.EqualValues(t, 0, rdb.Do(ctx, "GEOSEARCHSTORE", "dst", "src", "FROMMEMBER", "Shenzhen", "BYBOX", 88, 88, "m").Val())
})

t.Run("GEOSEARCH / GEOSEARCHSTORE FROMMEMBER against non existing member", func(t *testing.T) {
require.NoError(t, rdb.Do(ctx, "DEL", "src", "dst").Err())

require.NoError(t, rdb.Do(ctx, "GEOADD", "src", "10", "10", "Shenzhen").Err())
require.Error(t, rdb.Do(ctx, "GEOSEARCH", "src", "FROMMEMBER", "Shenzhen_2", "BYBOX", 88, 88, "M").Err())

require.NoError(t, rdb.Do(ctx, "GEOADD", "dst", "20", "20", "Guangzhou").Err())
require.Error(t, rdb.Do(ctx, "GEOSEARCHSTORE", "dst", "src", "FROMMEMBER", "Shenzhen_2", "BYBOX", 88, 88, "M").Err())
// Verify command does not affect dst
require.EqualValues(t, 1, rdb.Exists(ctx, "dst").Val())
})

t.Run("GEOSEARCHSTORE remove the dst key when there is no result set", func(t *testing.T) {
require.NoError(t, rdb.Do(ctx, "del", "src", "dst").Err())

Expand Down

0 comments on commit 640f947

Please sign in to comment.