Skip to content

Commit

Permalink
Remove HRANGE command from table due to #1082
Browse files Browse the repository at this point in the history
  • Loading branch information
PragmaTwice committed Nov 10, 2022
1 parent 127d5dd commit c84c41e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/commands/redis_cmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5998,7 +5998,6 @@ const CommandAttributes redisCommandTable[]{
MakeCmdAttr<CommandHVals>("hvals", 2, "read-only", 1, 1, 1),
MakeCmdAttr<CommandHGetAll>("hgetall", 2, "read-only", 1, 1, 1),
MakeCmdAttr<CommandHScan>("hscan", -3, "read-only", 1, 1, 1),
MakeCmdAttr<CommandHRange>("hrange", -4, "read-only", 1, 1, 1),

MakeCmdAttr<CommandLPush>("lpush", -3, "write", 1, 1, 1),
MakeCmdAttr<CommandRPush>("rpush", -3, "write", 1, 1, 1),
Expand Down
50 changes: 0 additions & 50 deletions tests/gocase/unit/type/hash/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,55 +613,5 @@ func TestHash(t *testing.T) {
}
})

kvArray := []string{"a", "a", "b", "b", "c", "c", "d", "d", "e", "e", "key1", "value1", "key2", "value2", "key3", "value3", "key10", "value10", "z", "z", "x", "x"}
t.Run("HRange normal situation ", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "hashkey").Err())
require.NoError(t, rdb.HMSet(ctx, "hashkey", kvArray).Err())
require.EqualValues(t, []interface{}{"key1", "value1", "key10", "value10"}, rdb.Do(ctx, "HRange", "hashkey", "key1", "key2", "limit", 100).Val())
require.EqualValues(t, []interface{}{"key1", "value1", "key10", "value10", "key2", "value2"}, rdb.Do(ctx, "HRange", "hashkey", "key1", "key3", "limit", 100).Val())
})

t.Run("HRange stop <= start", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "hashkey").Err())
require.NoError(t, rdb.HMSet(ctx, "hashkey", kvArray).Err())
require.EqualValues(t, []interface{}{}, rdb.Do(ctx, "HRange", "hashkey", "key2", "key1", "limit", 100).Val())
require.EqualValues(t, []interface{}{}, rdb.Do(ctx, "HRange", "hashkey", "key1", "key1", "limit", 100).Val())
})

t.Run("HRange limit", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "hashkey").Err())
require.NoError(t, rdb.HMSet(ctx, "hashkey", kvArray).Err())
require.EqualValues(t, []interface{}{"a", "a", "b", "b"}, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limit", 2).Val())
require.EqualValues(t, []interface{}{"a", "a", "b", "b", "c", "c", "d", "d", "e", "e", "key1", "value1", "key10", "value10", "key2", "value2", "key3", "value3", "x", "x", "z", "z"}, rdb.Do(ctx, "HRange", "hashkey", "a", "zzz", "limit", 10000).Val())
})

t.Run("HRange limit is negative", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "hashkey").Err())
require.NoError(t, rdb.HMSet(ctx, "hashkey", kvArray).Err())
require.EqualValues(t, []interface{}{}, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limit", -100).Val())
require.EqualValues(t, []interface{}{}, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limit", 0).Val())
})

t.Run("HRange nonexistent key", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "hashkey").Err())
require.EqualValues(t, []interface{}{}, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limit", 10000).Val())
require.EqualValues(t, []interface{}{}, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limit", 10000).Val())
})

t.Run("HRange limit typo", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "hashkey").Err())
require.NoError(t, rdb.HMSet(ctx, "hashkey", kvArray).Err())
require.ErrorContains(t, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limitzz", 10000).Err(), "ERR syntax")
})

t.Run("HRange wrong number of arguments", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "hashkey").Err())
require.NoError(t, rdb.HMSet(ctx, "hashkey", kvArray).Err())
require.ErrorContains(t, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limit", 10000, "a").Err(), "wrong number of arguments")
require.ErrorContains(t, rdb.Do(ctx, "HRange", "hashkey", "a", "z", "limit").Err(), "wrong number of arguments")
require.ErrorContains(t, rdb.Do(ctx, "HRange", "hashkey", "a").Err(), "wrong number of arguments")
require.ErrorContains(t, rdb.Do(ctx, "HRange", "hashkey").Err(), "wrong number of arguments")
require.ErrorContains(t, rdb.Do(ctx, "HRange").Err(), "wrong number of arguments")
})
}
}

0 comments on commit c84c41e

Please sign in to comment.