mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-06 09:17:10 +08:00
refactor command table
This commit is contained in:
32
aof_test.go
32
aof_test.go
@@ -34,31 +34,31 @@ func TestAof(t *testing.T) {
|
||||
for i := 0; i < size; i++ {
|
||||
key := strconv.Itoa(cursor)
|
||||
cursor++
|
||||
Set(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8), "EX", "10000"))
|
||||
execSet(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8), "EX", "10000"))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := strconv.Itoa(cursor)
|
||||
cursor++
|
||||
RPush(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
execRPush(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := strconv.Itoa(cursor)
|
||||
cursor++
|
||||
HSet(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8), utils2.RandString(8)))
|
||||
execHSet(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8), utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := strconv.Itoa(cursor)
|
||||
cursor++
|
||||
SAdd(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
execSAdd(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := strconv.Itoa(cursor)
|
||||
cursor++
|
||||
ZAdd(aofWriteDB, utils2.ToBytesList(key, "10", utils2.RandString(8)))
|
||||
execZAdd(aofWriteDB, utils2.ToBytesList(key, "10", utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
aofWriteDB.Close() // wait for aof finished
|
||||
@@ -105,44 +105,44 @@ func TestRewriteAOF(t *testing.T) {
|
||||
for i := 0; i < size; i++ {
|
||||
key := "str" + strconv.Itoa(cursor)
|
||||
cursor++
|
||||
Set(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
Set(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
execSet(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
execSet(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
// test ttl
|
||||
for i := 0; i < size; i++ {
|
||||
key := "str" + strconv.Itoa(cursor)
|
||||
cursor++
|
||||
Set(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8), "EX", "1000"))
|
||||
execSet(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8), "EX", "1000"))
|
||||
ttlKeys = append(ttlKeys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := "list" + strconv.Itoa(cursor)
|
||||
cursor++
|
||||
RPush(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
RPush(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
execRPush(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
execRPush(aofWriteDB, utils2.ToBytesList(key, utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := "hash" + strconv.Itoa(cursor)
|
||||
cursor++
|
||||
field := utils2.RandString(8)
|
||||
HSet(aofWriteDB, utils2.ToBytesList(key, field, utils2.RandString(8)))
|
||||
HSet(aofWriteDB, utils2.ToBytesList(key, field, utils2.RandString(8)))
|
||||
execHSet(aofWriteDB, utils2.ToBytesList(key, field, utils2.RandString(8)))
|
||||
execHSet(aofWriteDB, utils2.ToBytesList(key, field, utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := "set" + strconv.Itoa(cursor)
|
||||
cursor++
|
||||
member := utils2.RandString(8)
|
||||
SAdd(aofWriteDB, utils2.ToBytesList(key, member))
|
||||
SAdd(aofWriteDB, utils2.ToBytesList(key, member))
|
||||
execSAdd(aofWriteDB, utils2.ToBytesList(key, member))
|
||||
execSAdd(aofWriteDB, utils2.ToBytesList(key, member))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
for i := 0; i < size; i++ {
|
||||
key := "zset" + strconv.Itoa(cursor)
|
||||
cursor++
|
||||
ZAdd(aofWriteDB, utils2.ToBytesList(key, "10", utils2.RandString(8)))
|
||||
execZAdd(aofWriteDB, utils2.ToBytesList(key, "10", utils2.RandString(8)))
|
||||
keys = append(keys, key)
|
||||
}
|
||||
time.Sleep(time.Second) // wait for async goroutine finish its job
|
||||
@@ -167,7 +167,7 @@ func TestRewriteAOF(t *testing.T) {
|
||||
}
|
||||
}
|
||||
for _, key := range ttlKeys {
|
||||
ret := TTL(aofReadDB, utils2.ToBytesList(key))
|
||||
ret := execTTL(aofReadDB, utils2.ToBytesList(key))
|
||||
intResult, ok := ret.(*reply.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expected int reply, actually %s", ret.ToBytes())
|
||||
|
Reference in New Issue
Block a user