add more tests

master
kevin 4 years ago
parent 33faab61a3
commit c9b0ac1ee4

@ -636,22 +636,22 @@ func (cs clusterStore) ZrevrangebyscoreWithScoresAndLimit(key string, start, sto
return node.ZrevrangebyscoreWithScoresAndLimit(key, start, stop, page, size) return node.ZrevrangebyscoreWithScoresAndLimit(key, start, stop, page, size)
} }
func (cs clusterStore) Zscore(key string, value string) (int64, error) { func (cs clusterStore) Zrevrank(key, field string) (int64, error) {
node, err := cs.getRedis(key) node, err := cs.getRedis(key)
if err != nil { if err != nil {
return 0, err return 0, err
} }
return node.Zscore(key, value) return node.Zrevrank(key, field)
} }
func (cs clusterStore) Zrevrank(key, field string) (int64, error) { func (cs clusterStore) Zscore(key string, value string) (int64, error) {
node, err := cs.getRedis(key) node, err := cs.getRedis(key)
if err != nil { if err != nil {
return 0, err return 0, err
} }
return node.Zrevrank(key, field) return node.Zscore(key, value)
} }
func (cs clusterStore) getRedis(key string) (*redis.Redis, error) { func (cs clusterStore) getRedis(key string) (*redis.Redis, error) {

@ -516,6 +516,8 @@ func TestRedis_SortedSet(t *testing.T) {
assert.NotNil(t, err) assert.NotNil(t, err)
_, err = store.ZrevrangebyscoreWithScoresAndLimit("key", 5, 8, 1, 1) _, err = store.ZrevrangebyscoreWithScoresAndLimit("key", 5, 8, 1, 1)
assert.NotNil(t, err) assert.NotNil(t, err)
_, err = store.Zrevrank("key", "value")
assert.NotNil(t, err)
_, err = store.Zadds("key", redis.Pair{ _, err = store.Zadds("key", redis.Pair{
Key: "value2", Key: "value2",
Score: 6, Score: 6,
@ -640,6 +642,9 @@ func TestRedis_SortedSet(t *testing.T) {
Score: 5, Score: 5,
}, },
}, pairs) }, pairs)
rank, err = client.Zrevrank("key", "value1")
assert.Nil(t, err)
assert.Equal(t, int64(1), rank)
val, err = client.Zadds("key", redis.Pair{ val, err = client.Zadds("key", redis.Pair{
Key: "value2", Key: "value2",
Score: 6, Score: 6,

@ -713,6 +713,8 @@ func TestRedis_SortedSet(t *testing.T) {
pairs, err = client.ZrevrangebyscoreWithScoresAndLimit("key", 5, 8, 1, 0) pairs, err = client.ZrevrangebyscoreWithScoresAndLimit("key", 5, 8, 1, 0)
assert.Nil(t, err) assert.Nil(t, err)
assert.Equal(t, 0, len(pairs)) assert.Equal(t, 0, len(pairs))
_, err = NewRedis(client.Addr, "").Zrevrank("key", "value")
assert.NotNil(t, err)
}) })
} }

Loading…
Cancel
Save