mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 00:42:43 +08:00
chore: use t.Errorf(...) instead of t.Error(fmt.Sprintf(...))
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
"github.com/hdt3213/godis/redis/protocol/asserts"
|
||||
@@ -48,7 +47,7 @@ func TestDumpKeyAndRenameTo(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("ttl", newKey))
|
||||
intResult, ok := result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
"github.com/hdt3213/godis/redis/protocol/asserts"
|
||||
@@ -74,7 +73,7 @@ func TestGeoDist(t *testing.T) {
|
||||
result := execGeoDist(testDB, utils.ToCmdLine(key, pos1, pos2, "km"))
|
||||
bulkReply, ok := result.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
dist, err := strconv.ParseFloat(string(bulkReply.Arg), 10)
|
||||
@@ -89,7 +88,7 @@ func TestGeoDist(t *testing.T) {
|
||||
result = execGeoDist(testDB, utils.ToCmdLine(key, pos1, pos2, "m"))
|
||||
bulkReply, ok = result.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
dist, err = strconv.ParseFloat(string(bulkReply.Arg), 10)
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
"github.com/hdt3213/godis/redis/protocol/asserts"
|
||||
@@ -23,7 +22,7 @@ func TestHSet(t *testing.T) {
|
||||
values[field] = []byte(value)
|
||||
result := testDB.Exec(nil, utils.ToCmdLine("hset", key, field, value))
|
||||
if intResult, _ := result.(*protocol.IntReply); intResult.Code != int64(1) {
|
||||
t.Error(fmt.Sprintf("expected %d, actually %d", 1, intResult.Code))
|
||||
t.Errorf("expected %d, actually %d", 1, intResult.Code)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,23 +31,23 @@ func TestHSet(t *testing.T) {
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("hget", key, field))
|
||||
expected := protocol.MakeBulkReply(v)
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error(fmt.Sprintf("expected %s, actually %s", string(expected.ToBytes()), string(actual.ToBytes())))
|
||||
t.Errorf("expected %s, actually %s", string(expected.ToBytes()), string(actual.ToBytes()))
|
||||
}
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("hexists", key, field))
|
||||
if intResult, _ := actual.(*protocol.IntReply); intResult.Code != int64(1) {
|
||||
t.Error(fmt.Sprintf("expected %d, actually %d", 1, intResult.Code))
|
||||
t.Errorf("expected %d, actually %d", 1, intResult.Code)
|
||||
}
|
||||
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("hstrlen", key, field))
|
||||
if intResult, _ := actual.(*protocol.IntReply); intResult.Code != int64(len(v)) {
|
||||
t.Error(fmt.Sprintf("expected %d, actually %d", int64(len(v)), intResult.Code))
|
||||
t.Errorf("expected %d, actually %d", int64(len(v)), intResult.Code)
|
||||
}
|
||||
}
|
||||
|
||||
// test hlen
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("hlen", key))
|
||||
if intResult, _ := actual.(*protocol.IntReply); intResult.Code != int64(len(values)) {
|
||||
t.Error(fmt.Sprintf("expected %d, actually %d", len(values), intResult.Code))
|
||||
t.Errorf("expected %d, actually %d", len(values), intResult.Code)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,12 +70,12 @@ func TestHDel(t *testing.T) {
|
||||
args = append(args, fields...)
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine2("hdel", args...))
|
||||
if intResult, _ := actual.(*protocol.IntReply); intResult.Code != int64(len(fields)) {
|
||||
t.Error(fmt.Sprintf("expected %d, actually %d", len(fields), intResult.Code))
|
||||
t.Errorf("expected %d, actually %d", len(fields), intResult.Code)
|
||||
}
|
||||
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("hlen", key))
|
||||
if intResult, _ := actual.(*protocol.IntReply); intResult.Code != int64(0) {
|
||||
t.Error(fmt.Sprintf("expected %d, actually %d", 0, intResult.Code))
|
||||
t.Errorf("expected %d, actually %d", 0, intResult.Code)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +95,7 @@ func TestHMSet(t *testing.T) {
|
||||
}
|
||||
result := testDB.Exec(nil, utils.ToCmdLine2("hmset", setArgs...))
|
||||
if _, ok := result.(*protocol.OkReply); !ok {
|
||||
t.Error(fmt.Sprintf("expected ok, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected ok, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
|
||||
// test HMGet
|
||||
@@ -105,7 +104,7 @@ func TestHMSet(t *testing.T) {
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine2("hmget", getArgs...))
|
||||
expected := protocol.MakeMultiBulkReply(utils.ToCmdLine(values...))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error(fmt.Sprintf("expected %s, actually %s", string(expected.ToBytes()), string(actual.ToBytes())))
|
||||
t.Errorf("expected %s, actually %s", string(expected.ToBytes()), string(actual.ToBytes()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,21 +129,21 @@ func TestHGetAll(t *testing.T) {
|
||||
result := testDB.Exec(nil, utils.ToCmdLine("hgetall", key))
|
||||
multiBulk, ok := result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
if 2*len(fields) != len(multiBulk.Args) {
|
||||
t.Error(fmt.Sprintf("expected %d items , actually %d ", 2*len(fields), len(multiBulk.Args)))
|
||||
t.Errorf("expected %d items , actually %d ", 2*len(fields), len(multiBulk.Args))
|
||||
}
|
||||
for i := range fields {
|
||||
field := string(multiBulk.Args[2*i])
|
||||
actual := string(multiBulk.Args[2*i+1])
|
||||
expected, ok := valueMap[field]
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("unexpected field %s", field))
|
||||
t.Errorf("unexpected field %s", field)
|
||||
continue
|
||||
}
|
||||
if actual != expected {
|
||||
t.Error(fmt.Sprintf("expected %s, actually %s", expected, actual))
|
||||
t.Errorf("expected %s, actually %s", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,15 +151,15 @@ func TestHGetAll(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hkeys", key))
|
||||
multiBulk, ok = result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
if len(fields) != len(multiBulk.Args) {
|
||||
t.Error(fmt.Sprintf("expected %d items , actually %d ", len(fields), len(multiBulk.Args)))
|
||||
t.Errorf("expected %d items , actually %d ", len(fields), len(multiBulk.Args))
|
||||
}
|
||||
for _, v := range multiBulk.Args {
|
||||
field := string(v)
|
||||
if _, ok := valueMap[field]; !ok {
|
||||
t.Error(fmt.Sprintf("unexpected field %s", field))
|
||||
t.Errorf("unexpected field %s", field)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,16 +167,16 @@ func TestHGetAll(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hvals", key))
|
||||
multiBulk, ok = result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
if len(fields) != len(multiBulk.Args) {
|
||||
t.Error(fmt.Sprintf("expected %d items , actually %d ", len(fields), len(multiBulk.Args)))
|
||||
t.Errorf("expected %d items , actually %d ", len(fields), len(multiBulk.Args))
|
||||
}
|
||||
for _, v := range multiBulk.Args {
|
||||
value := string(v)
|
||||
_, ok := valueSet[value]
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("unexpected value %s", value))
|
||||
t.Errorf("unexpected value %s", value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +187,7 @@ func TestHGetAll(t *testing.T) {
|
||||
if !ok {
|
||||
resultBytes := string(result.ToBytes())
|
||||
if resultBytes != "*0\r\n" {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", resultBytes))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", resultBytes)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,40 +195,40 @@ func TestHGetAll(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hrandfield", key, strconv.Itoa(size+100)))
|
||||
multiBulk, ok = result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
if len(fields) != len(multiBulk.Args) {
|
||||
t.Error(fmt.Sprintf("expected %d items , actually %d ", len(fields), len(multiBulk.Args)))
|
||||
t.Errorf("expected %d items , actually %d ", len(fields), len(multiBulk.Args))
|
||||
}
|
||||
|
||||
// test HRandField count > size withvalues
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hrandfield", key, strconv.Itoa(size+100), "withvalues"))
|
||||
multiBulk, ok = result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
if 2*len(fields) != len(multiBulk.Args) {
|
||||
t.Error(fmt.Sprintf("expected %d items , actually %d ", 2*len(fields), len(multiBulk.Args)))
|
||||
t.Errorf("expected %d items , actually %d ", 2*len(fields), len(multiBulk.Args))
|
||||
}
|
||||
|
||||
// test HRandField count < size
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hrandfield", key, strconv.Itoa(-size-10)))
|
||||
multiBulk, ok = result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
if len(fields)+10 != len(multiBulk.Args) {
|
||||
t.Error(fmt.Sprintf("expected %d items , actually %d ", len(fields)+10, len(multiBulk.Args)))
|
||||
t.Errorf("expected %d items , actually %d ", len(fields)+10, len(multiBulk.Args))
|
||||
}
|
||||
|
||||
// test HRandField count < size withvalues
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hrandfield", key, strconv.Itoa(-size-10), "withvalues"))
|
||||
multiBulk, ok = result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected MultiBulkReply, actually %s", string(result.ToBytes())))
|
||||
t.Errorf("expected MultiBulkReply, actually %s", string(result.ToBytes()))
|
||||
}
|
||||
if 2*(len(fields)+10) != len(multiBulk.Args) {
|
||||
t.Error(fmt.Sprintf("expected %d items , actually %d ", 2*(len(fields)+10), len(multiBulk.Args)))
|
||||
t.Errorf("expected %d items , actually %d ", 2*(len(fields)+10), len(multiBulk.Args))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,25 +238,25 @@ func TestHIncrBy(t *testing.T) {
|
||||
key := utils.RandString(10)
|
||||
result := testDB.Exec(nil, utils.ToCmdLine("hincrby", key, "a", "1"))
|
||||
if bulkResult, _ := result.(*protocol.BulkReply); string(bulkResult.Arg) != "1" {
|
||||
t.Error(fmt.Sprintf("expected %s, actually %s", "1", string(bulkResult.Arg)))
|
||||
t.Errorf("expected %s, actually %s", "1", string(bulkResult.Arg))
|
||||
}
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hincrby", key, "a", "1"))
|
||||
if bulkResult, _ := result.(*protocol.BulkReply); string(bulkResult.Arg) != "2" {
|
||||
t.Error(fmt.Sprintf("expected %s, actually %s", "2", string(bulkResult.Arg)))
|
||||
t.Errorf("expected %s, actually %s", "2", string(bulkResult.Arg))
|
||||
}
|
||||
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hincrbyfloat", key, "b", "1.2"))
|
||||
if bulkResult, ok := result.(*protocol.BulkReply); ok {
|
||||
val, _ := strconv.ParseFloat(string(bulkResult.Arg), 10)
|
||||
if math.Abs(val-1.2) > 1e-4 {
|
||||
t.Error(fmt.Sprintf("expected %s, actually %s", "1.2", string(bulkResult.Arg)))
|
||||
t.Errorf("expected %s, actually %s", "1.2", string(bulkResult.Arg))
|
||||
}
|
||||
}
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("hincrbyfloat", key, "b", "1.2"))
|
||||
if bulkResult, ok := result.(*protocol.BulkReply); ok {
|
||||
val, _ := strconv.ParseFloat(string(bulkResult.Arg), 10)
|
||||
if math.Abs(val-2.4) > 1e-4 {
|
||||
t.Error(fmt.Sprintf("expected %s, actually %s", "1.2", string(bulkResult.Arg)))
|
||||
t.Errorf("expected %s, actually %s", "1.2", string(bulkResult.Arg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/connection"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
@@ -73,7 +72,7 @@ func TestRename(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("ttl", newKey))
|
||||
intResult, ok := result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
@@ -97,7 +96,7 @@ func TestRenameNx(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("ttl", newKey))
|
||||
intResult, ok := result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
@@ -117,7 +116,7 @@ func TestTTL(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("ttl", key))
|
||||
intResult, ok := result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
@@ -135,7 +134,7 @@ func TestTTL(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("PTTL", key))
|
||||
intResult, ok = result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
@@ -168,7 +167,7 @@ func TestExpireAt(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("ttl", key))
|
||||
intResult, ok := result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
@@ -182,7 +181,7 @@ func TestExpireAt(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("ttl", key))
|
||||
intResult, ok = result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
@@ -210,7 +209,7 @@ func TestExpiredTime(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("ttl", key))
|
||||
intResult, ok := result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code < 0 || intResult.Code > 2 {
|
||||
@@ -221,7 +220,7 @@ func TestExpiredTime(t *testing.T) {
|
||||
asserts.AssertIntReply(t, result, int(time.Now().Add(2*time.Second).Unix()))
|
||||
intResult, ok = result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
@@ -233,7 +232,7 @@ func TestExpiredTime(t *testing.T) {
|
||||
asserts.AssertIntReply(t, result, int(time.Now().Add(2*time.Second).UnixMilli()))
|
||||
intResult, ok = result.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
"github.com/hdt3213/godis/redis/protocol/asserts"
|
||||
@@ -37,11 +36,11 @@ func TestSAdd(t *testing.T) {
|
||||
result = testDB.Exec(nil, utils.ToCmdLine("SMembers", key))
|
||||
multiBulk, ok := result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
if len(multiBulk.Args) != size {
|
||||
t.Error(fmt.Sprintf("expected %d elements, actually %d", size, len(multiBulk.Args)))
|
||||
t.Errorf("expected %d elements, actually %d", size, len(multiBulk.Args))
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -84,7 +83,7 @@ func TestSPop(t *testing.T) {
|
||||
resultSpop := testDB.Exec(nil, utils.ToCmdLine("spop", key, strconv.FormatInt(int64(count), 10)))
|
||||
multiBulk, ok := resultSpop.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", resultSpop.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", resultSpop.ToBytes())
|
||||
return
|
||||
}
|
||||
removedSize := len(multiBulk.Args)
|
||||
@@ -220,7 +219,7 @@ func TestSRandMember(t *testing.T) {
|
||||
result := testDB.Exec(nil, utils.ToCmdLine("SRandMember", key))
|
||||
br, ok := result.(*protocol.BulkReply)
|
||||
if !ok && len(br.Arg) > 0 {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -228,7 +227,7 @@ func TestSRandMember(t *testing.T) {
|
||||
asserts.AssertMultiBulkReplySize(t, result, 10)
|
||||
multiBulk, ok := result.(*protocol.MultiBulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", result.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", result.ToBytes())
|
||||
return
|
||||
}
|
||||
m := make(map[string]struct{})
|
||||
@@ -236,7 +235,7 @@ func TestSRandMember(t *testing.T) {
|
||||
m[string(arg)] = struct{}{}
|
||||
}
|
||||
if len(m) != 10 {
|
||||
t.Error(fmt.Sprintf("expected 10 members, actually %d", len(m)))
|
||||
t.Errorf("expected 10 members, actually %d", len(m))
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -94,11 +94,11 @@ func TestSet(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000 {
|
||||
t.Error(fmt.Sprintf("expected int between [0, 1000], actually %d", intResult.Code))
|
||||
t.Errorf("expected int between [0, 1000], actually %d", intResult.Code)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -111,11 +111,11 @@ func TestSet(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok = actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000 {
|
||||
t.Error(fmt.Sprintf("expected int between [0, 1000], actually %d", intResult.Code))
|
||||
t.Errorf("expected int between [0, 1000], actually %d", intResult.Code)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -150,11 +150,11 @@ func TestSetEX(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000 {
|
||||
t.Error(fmt.Sprintf("expected int between [0, 1000], actually %d", intResult.Code))
|
||||
t.Errorf("expected int between [0, 1000], actually %d", intResult.Code)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -171,11 +171,11 @@ func TestPSetEX(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("PTTL", key))
|
||||
intResult, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000000 {
|
||||
t.Error(fmt.Sprintf("expected int between [0, 1000], actually %d", intResult.Code))
|
||||
t.Errorf("expected int between [0, 1000], actually %d", intResult.Code)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -252,7 +252,7 @@ func TestIncr(t *testing.T) {
|
||||
expected := -i - 1
|
||||
bulk, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
val, err := strconv.ParseFloat(string(bulk.Arg), 10)
|
||||
@@ -283,7 +283,7 @@ func TestDecr(t *testing.T) {
|
||||
expected := -i - 1
|
||||
bulk, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected bulk protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
val, err := strconv.ParseFloat(string(bulk.Arg), 10)
|
||||
@@ -316,11 +316,11 @@ func TestGetEX(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000 {
|
||||
t.Error(fmt.Sprintf("expected int between [0, 1000], actually %d", intResult.Code))
|
||||
t.Errorf("expected int between [0, 1000], actually %d", intResult.Code)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -330,11 +330,11 @@ func TestGetEX(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok = actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code != -1 {
|
||||
t.Error(fmt.Sprintf("expected int equals -1, actually %d", intResult.Code))
|
||||
t.Errorf("expected int equals -1, actually %d", intResult.Code)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -345,11 +345,11 @@ func TestGetEX(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok = actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
t.Errorf("expected int protocol, actually %s", actual.ToBytes())
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000000 {
|
||||
t.Error(fmt.Sprintf("expected int between [0, 1000000], actually %d", intResult.Code))
|
||||
t.Errorf("expected int between [0, 1000000], actually %d", intResult.Code)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user