|
|
|
@ -507,6 +507,14 @@ func TestRedis_List(t *testing.T) {
|
|
|
|
|
vals, err = client.Lrange("key", 0, 10)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
assert.EqualValues(t, []string{"value2", "value3"}, vals)
|
|
|
|
|
vals, err = client.LpopCount("key", 2)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
assert.EqualValues(t, []string{"value2", "value3"}, vals)
|
|
|
|
|
_, err = client.Lpush("key", "value1", "value2")
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
vals, err = client.RpopCount("key", 4)
|
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
assert.EqualValues(t, []string{"value1", "value2"}, vals)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -523,6 +531,34 @@ func TestRedis_List(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
_, err = client.Rpush("key", "value3", "value4")
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
|
|
_, err = client.LpopCount("key", 2)
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
|
|
_, err = client.RpopCount("key", 2)
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
t.Run("list redis type error", func(t *testing.T) {
|
|
|
|
|
runOnRedisWithError(t, func(client *Redis) {
|
|
|
|
|
client.Type = "nil"
|
|
|
|
|
_, err := client.Llen("key")
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
|
|
_, err = client.Lpush("key", "value1", "value2")
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
|
|
_, err = client.Lrem("key", 2, "value1")
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
|
|
_, err = client.Rpush("key", "value3", "value4")
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
|
|
_, err = client.LpopCount("key", 2)
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
|
|
_, err = client.RpopCount("key", 2)
|
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|