1 Star 0 Fork 0

kean/redis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
list_test.go 1.37 KB
一键复制 编辑 原始数据 按行查看 历史
package redis
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestLPushCommand(t *testing.T) {
i, err := c.LPush("lpushkey", "va").Result()
assert.NoError(t, err)
assert.Equal(t, int64(1), i)
i, err = c.LPush("lpushkey", "vb").Result()
assert.NoError(t, err)
assert.Equal(t, int64(2), i)
i, err = c.LPush("lpushkey", "vc", "vd").Result()
assert.NoError(t, err)
assert.Equal(t, int64(4), i)
i, err = c.LPush("lpushkey2", "1", "2").Result()
assert.NoError(t, err)
assert.Equal(t, int64(2), i)
i, err = c.LPush("lpush3key").Result()
assert.Error(t, err)
}
func TestLPopCommand(t *testing.T) {
s, err := c.LPop("lpop1").Result()
assert.Zero(t, s)
assert.Error(t, err)
i, err := c.LPush("list", "a", "b").Result()
assert.NoError(t, err)
assert.Equal(t, int64(2), i)
s, err = c.LPop("list").Result()
assert.NoError(t, err)
assert.Equal(t, "b", s)
s, err = c.LPop("list").Result()
assert.NoError(t, err)
assert.Equal(t, "a", s)
s, err = c.LPop("list").Result()
assert.Error(t, err)
assert.Zero(t, s)
}
func TestLRangeCommand(t *testing.T) {
s, err := c.LRange("lrange", 0, 0).Result()
assert.Error(t, err)
assert.Zero(t, s)
sl, err := c.Set("works", "esfkjsefj", 0).Result()
assert.NoError(t, err)
assert.NotZero(t, sl)
assert.NotEmpty(t, sl)
i, err := c.LPush("list2", "a", "b").Result()
assert.NoError(t, err)
assert.Equal(t, int64(2), i)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kean123/redis.git
[email protected]:kean123/redis.git
kean123
redis
redis
master

搜索帮助