mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 16:57:06 +08:00
rename godis/redis/reply to godis/redis/protocol
This commit is contained in:
@@ -3,8 +3,8 @@ package database
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/reply"
|
||||
"github.com/hdt3213/godis/redis/reply/asserts"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
"github.com/hdt3213/godis/redis/protocol/asserts"
|
||||
"strconv"
|
||||
"testing"
|
||||
)
|
||||
@@ -18,7 +18,7 @@ func TestSet2(t *testing.T) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
testDB.Exec(nil, utils.ToCmdLine("SET", key, value))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := reply.MakeBulkReply([]byte(value))
|
||||
expected := protocol.MakeBulkReply([]byte(value))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
@@ -33,14 +33,14 @@ func TestSet(t *testing.T) {
|
||||
// normal set
|
||||
testDB.Exec(nil, utils.ToCmdLine("SET", key, value))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := reply.MakeBulkReply([]byte(value))
|
||||
expected := protocol.MakeBulkReply([]byte(value))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
|
||||
// set nx
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("SET", key, value, "NX"))
|
||||
if _, ok := actual.(*reply.NullBulkReply); !ok {
|
||||
if _, ok := actual.(*protocol.NullBulkReply); !ok {
|
||||
t.Error("expected true actual false")
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestSet(t *testing.T) {
|
||||
value = utils.RandString(10)
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("SET", key, value, "NX"))
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected = reply.MakeBulkReply([]byte(value))
|
||||
expected = protocol.MakeBulkReply([]byte(value))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func TestSet(t *testing.T) {
|
||||
key = utils.RandString(10)
|
||||
value = utils.RandString(10)
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("SET", key, value, "XX"))
|
||||
if _, ok := actual.(*reply.NullBulkReply); !ok {
|
||||
if _, ok := actual.(*protocol.NullBulkReply); !ok {
|
||||
t.Error("expected true actually false ")
|
||||
}
|
||||
|
||||
@@ -77,9 +77,9 @@ func TestSet(t *testing.T) {
|
||||
asserts.AssertBulkReply(t, actual, value)
|
||||
actual = execTTL(testDB, utils.ToCmdLine(key))
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok := actual.(*reply.IntReply)
|
||||
intResult, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int reply, actually %s", actual.ToBytes()))
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000 {
|
||||
@@ -94,9 +94,9 @@ func TestSet(t *testing.T) {
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
asserts.AssertBulkReply(t, actual, value)
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok = actual.(*reply.IntReply)
|
||||
intResult, ok = actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int reply, actually %s", actual.ToBytes()))
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000 {
|
||||
@@ -111,13 +111,13 @@ func TestSetNX(t *testing.T) {
|
||||
value := utils.RandString(10)
|
||||
testDB.Exec(nil, utils.ToCmdLine("SETNX", key, value))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := reply.MakeBulkReply([]byte(value))
|
||||
expected := protocol.MakeBulkReply([]byte(value))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("SETNX", key, value))
|
||||
expected2 := reply.MakeIntReply(int64(0))
|
||||
expected2 := protocol.MakeIntReply(int64(0))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected2.ToBytes()) {
|
||||
t.Error("expected: " + string(expected2.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
@@ -133,9 +133,9 @@ func TestSetEX(t *testing.T) {
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
asserts.AssertBulkReply(t, actual, value)
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("TTL", key))
|
||||
intResult, ok := actual.(*reply.IntReply)
|
||||
intResult, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int reply, actually %s", actual.ToBytes()))
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000 {
|
||||
@@ -154,9 +154,9 @@ func TestPSetEX(t *testing.T) {
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
asserts.AssertBulkReply(t, actual, value)
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine("PTTL", key))
|
||||
intResult, ok := actual.(*reply.IntReply)
|
||||
intResult, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected int reply, actually %s", actual.ToBytes()))
|
||||
t.Error(fmt.Sprintf("expected int protocol, actually %s", actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
if intResult.Code <= 0 || intResult.Code > 1000000 {
|
||||
@@ -179,7 +179,7 @@ func TestMSet(t *testing.T) {
|
||||
}
|
||||
testDB.Exec(nil, utils.ToCmdLine2("MSET", args...))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine2("MGET", keys...))
|
||||
expected := reply.MakeMultiBulkReply(values)
|
||||
expected := protocol.MakeMultiBulkReply(values)
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func TestMSet(t *testing.T) {
|
||||
key2 := utils.RandString(10)
|
||||
testDB.Exec(nil, utils.ToCmdLine2("LPush", key2, key2))
|
||||
actual = testDB.Exec(nil, utils.ToCmdLine2("MGET", key1, key2))
|
||||
arr := actual.(*reply.MultiBulkReply)
|
||||
arr := actual.(*protocol.MultiBulkReply)
|
||||
if string(arr.Args[0]) != key1 {
|
||||
t.Error("expected: " + key1 + ", actual: " + string(arr.Args[1]))
|
||||
}
|
||||
@@ -206,7 +206,7 @@ func TestIncr(t *testing.T) {
|
||||
for i := 0; i < size; i++ {
|
||||
testDB.Exec(nil, utils.ToCmdLine("INCR", key))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := reply.MakeBulkReply([]byte(strconv.FormatInt(int64(i+1), 10)))
|
||||
expected := protocol.MakeBulkReply([]byte(strconv.FormatInt(int64(i+1), 10)))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func TestIncr(t *testing.T) {
|
||||
for i := 0; i < size; i++ {
|
||||
testDB.Exec(nil, utils.ToCmdLine("INCRBY", key, "-1"))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := reply.MakeBulkReply([]byte(strconv.FormatInt(int64(size-i-1), 10)))
|
||||
expected := protocol.MakeBulkReply([]byte(strconv.FormatInt(int64(size-i-1), 10)))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
@@ -225,7 +225,7 @@ func TestIncr(t *testing.T) {
|
||||
for i := 0; i < size; i++ {
|
||||
testDB.Exec(nil, utils.ToCmdLine("INCRBY", key, "1"))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := reply.MakeBulkReply([]byte(strconv.FormatInt(int64(i+1), 10)))
|
||||
expected := protocol.MakeBulkReply([]byte(strconv.FormatInt(int64(i+1), 10)))
|
||||
if !utils.BytesEquals(actual.ToBytes(), expected.ToBytes()) {
|
||||
t.Error("expected: " + string(expected.ToBytes()) + ", actual: " + string(actual.ToBytes()))
|
||||
}
|
||||
@@ -235,9 +235,9 @@ func TestIncr(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine("INCRBYFLOAT", key, "-1.0"))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := -i - 1
|
||||
bulk, ok := actual.(*reply.BulkReply)
|
||||
bulk, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk reply, actually %s", actual.ToBytes()))
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
val, err := strconv.ParseFloat(string(bulk.Arg), 10)
|
||||
@@ -266,9 +266,9 @@ func TestDecr(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine("DECRBY", key, "1"))
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GET", key))
|
||||
expected := -i - 1
|
||||
bulk, ok := actual.(*reply.BulkReply)
|
||||
bulk, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Error(fmt.Sprintf("expected bulk reply, actually %s", actual.ToBytes()))
|
||||
t.Error(fmt.Sprintf("expected bulk protocol, actually %s", actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
val, err := strconv.ParseFloat(string(bulk.Arg), 10)
|
||||
@@ -289,9 +289,9 @@ func TestGetSet(t *testing.T) {
|
||||
value := utils.RandString(10)
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GETSET", key, value))
|
||||
_, ok := actual.(*reply.NullBulkReply)
|
||||
_, ok := actual.(*protocol.NullBulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect null bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect null bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -323,9 +323,9 @@ func TestStrLen(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("StrLen", key))
|
||||
len, ok := actual.(*reply.IntReply)
|
||||
len, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expect int bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect int bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
asserts.AssertIntReply(t, len, 10)
|
||||
@@ -336,9 +336,9 @@ func TestStrLen_KeyNotExist(t *testing.T) {
|
||||
key := utils.RandString(10)
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("StrLen", key))
|
||||
result, ok := actual.(*reply.IntReply)
|
||||
result, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expect null bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect null bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -352,9 +352,9 @@ func TestAppend_KeyExist(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("Append", key, key2))
|
||||
val, ok := actual.(*reply.IntReply)
|
||||
val, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expect nil bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect nil bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
asserts.AssertIntReply(t, val, len(key)*2)
|
||||
@@ -365,9 +365,9 @@ func TestAppend_KeyNotExist(t *testing.T) {
|
||||
key := utils.RandString(10)
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("Append", key, key))
|
||||
val, ok := actual.(*reply.IntReply)
|
||||
val, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expect nil bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect nil bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
asserts.AssertIntReply(t, val, len(key))
|
||||
@@ -380,9 +380,9 @@ func TestSetRange_StringExist(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("SetRange", key, fmt.Sprint(0), key2))
|
||||
val, ok := actual.(*reply.IntReply)
|
||||
val, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expect int bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect int bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -398,9 +398,9 @@ func TestSetRange_StringExist_OffsetOutOfLen(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("SetRange", key, fmt.Sprint(len(key)+emptyByteLen), key2))
|
||||
val, ok := actual.(*reply.IntReply)
|
||||
val, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expect int bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect int bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -413,9 +413,9 @@ func TestSetRange_StringNotExist(t *testing.T) {
|
||||
key := utils.RandString(10)
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("SetRange", key, fmt.Sprint(0), key))
|
||||
val, ok := actual.(*reply.IntReply)
|
||||
val, ok := actual.(*protocol.IntReply)
|
||||
if !ok {
|
||||
t.Errorf("expect int bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect int bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
asserts.AssertIntReply(t, val, len(key))
|
||||
@@ -427,9 +427,9 @@ func TestGetRange_StringExist(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), fmt.Sprint(len(key))))
|
||||
val, ok := actual.(*reply.BulkReply)
|
||||
val, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -442,9 +442,9 @@ func TestGetRange_RangeLargeThenDataLen(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), fmt.Sprint(len(key)+2)))
|
||||
val, ok := actual.(*reply.BulkReply)
|
||||
val, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -455,9 +455,9 @@ func TestGetRange_StringNotExist(t *testing.T) {
|
||||
testDB.Flush()
|
||||
key := utils.RandString(10)
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), fmt.Sprint(len(key))))
|
||||
val, ok := actual.(*reply.NullBulkReply)
|
||||
val, ok := actual.(*protocol.NullBulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect nil bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect nil bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -470,9 +470,9 @@ func TestGetRange_StringExist_GetPartial(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), fmt.Sprint(len(key)/2)))
|
||||
val, ok := actual.(*reply.BulkReply)
|
||||
val, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -486,9 +486,9 @@ func TestGetRange_StringExist_EndIdxOutOfRange(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), fmt.Sprint(len(key)+emptyByteLen)))
|
||||
val, ok := actual.(*reply.BulkReply)
|
||||
val, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -502,9 +502,9 @@ func TestGetRange_StringExist_StartIdxEndIdxAreSame(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(len(key)+emptyByteLen), fmt.Sprint(len(key)+emptyByteLen)))
|
||||
val, ok := actual.(*reply.NullBulkReply)
|
||||
val, ok := actual.(*protocol.NullBulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect nil bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect nil bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -516,9 +516,9 @@ func TestGetRange_StringExist_StartIdxGreaterThanEndIdx(t *testing.T) {
|
||||
key := utils.RandString(10)
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(len(key)+1), fmt.Sprint(len(key))))
|
||||
val, ok := actual.(*reply.NullBulkReply)
|
||||
val, ok := actual.(*protocol.NullBulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect nil bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect nil bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -531,9 +531,9 @@ func TestGetRange_StringExist_StartIdxEndIdxAreNegative(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(-1*len(key)), fmt.Sprint(-1)))
|
||||
val, ok := actual.(*reply.BulkReply)
|
||||
val, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -546,9 +546,9 @@ func TestGetRange_StringExist_StartIdxNegative(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(-1*len(key)), fmt.Sprint(len(key)/2)))
|
||||
val, ok := actual.(*reply.BulkReply)
|
||||
val, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -561,9 +561,9 @@ func TestGetRange_StringExist_EndIdxNegative(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), fmt.Sprint(-len(key)/2)))
|
||||
val, ok := actual.(*reply.BulkReply)
|
||||
val, ok := actual.(*protocol.BulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -576,9 +576,9 @@ func TestGetRange_StringExist_StartIsOutOfRange(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(-len(key)-3), fmt.Sprint(len(key))))
|
||||
val, ok := actual.(*reply.NullBulkReply)
|
||||
val, ok := actual.(*protocol.NullBulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -591,9 +591,9 @@ func TestGetRange_StringExist_EndIdxIsOutOfRange(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), fmt.Sprint(-len(key)-3)))
|
||||
val, ok := actual.(*reply.NullBulkReply)
|
||||
val, ok := actual.(*protocol.NullBulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -606,9 +606,9 @@ func TestGetRange_StringExist_StartIdxGreaterThanDataLen(t *testing.T) {
|
||||
testDB.Exec(nil, utils.ToCmdLine2("SET", key, key))
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(len(key)+1), fmt.Sprint(0)))
|
||||
val, ok := actual.(*reply.NullBulkReply)
|
||||
val, ok := actual.(*protocol.NullBulkReply)
|
||||
if !ok {
|
||||
t.Errorf("expect bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -622,9 +622,9 @@ func TestGetRange_StringExist_StartIdxIncorrectFormat(t *testing.T) {
|
||||
incorrectValue := "incorrect"
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, incorrectValue, fmt.Sprint(0)))
|
||||
val, ok := actual.(*reply.StandardErrReply)
|
||||
val, ok := actual.(*protocol.StandardErrReply)
|
||||
if !ok {
|
||||
t.Errorf("expect standart bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect standart bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -639,9 +639,9 @@ func TestGetRange_StringExist_EndIdxIncorrectFormat(t *testing.T) {
|
||||
incorrectValue := "incorrect"
|
||||
|
||||
actual := testDB.Exec(nil, utils.ToCmdLine("GetRange", key, fmt.Sprint(0), incorrectValue))
|
||||
val, ok := actual.(*reply.StandardErrReply)
|
||||
val, ok := actual.(*protocol.StandardErrReply)
|
||||
if !ok {
|
||||
t.Errorf("expect standart bulk reply, get: %s", string(actual.ToBytes()))
|
||||
t.Errorf("expect standart bulk protocol, get: %s", string(actual.ToBytes()))
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user