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:
@@ -4,32 +4,32 @@ import (
|
||||
"bytes"
|
||||
"github.com/hdt3213/godis/interface/redis"
|
||||
"github.com/hdt3213/godis/lib/utils"
|
||||
"github.com/hdt3213/godis/redis/reply"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseStream(t *testing.T) {
|
||||
replies := []redis.Reply{
|
||||
reply.MakeIntReply(1),
|
||||
reply.MakeStatusReply("OK"),
|
||||
reply.MakeErrReply("ERR unknown"),
|
||||
reply.MakeBulkReply([]byte("a\r\nb")), // test binary safe
|
||||
reply.MakeNullBulkReply(),
|
||||
reply.MakeMultiBulkReply([][]byte{
|
||||
protocol.MakeIntReply(1),
|
||||
protocol.MakeStatusReply("OK"),
|
||||
protocol.MakeErrReply("ERR unknown"),
|
||||
protocol.MakeBulkReply([]byte("a\r\nb")), // test binary safe
|
||||
protocol.MakeNullBulkReply(),
|
||||
protocol.MakeMultiBulkReply([][]byte{
|
||||
[]byte("a"),
|
||||
[]byte("\r\n"),
|
||||
}),
|
||||
reply.MakeEmptyMultiBulkReply(),
|
||||
protocol.MakeEmptyMultiBulkReply(),
|
||||
}
|
||||
reqs := bytes.Buffer{}
|
||||
for _, re := range replies {
|
||||
reqs.Write(re.ToBytes())
|
||||
}
|
||||
reqs.Write([]byte("set a a" + reply.CRLF)) // test text protocol
|
||||
reqs.Write([]byte("set a a" + protocol.CRLF)) // test text protocol
|
||||
expected := make([]redis.Reply, len(replies))
|
||||
copy(expected, replies)
|
||||
expected = append(expected, reply.MakeMultiBulkReply([][]byte{
|
||||
expected = append(expected, protocol.MakeMultiBulkReply([][]byte{
|
||||
[]byte("set"), []byte("a"), []byte("a"),
|
||||
}))
|
||||
|
||||
@@ -57,16 +57,16 @@ func TestParseStream(t *testing.T) {
|
||||
|
||||
func TestParseOne(t *testing.T) {
|
||||
replies := []redis.Reply{
|
||||
reply.MakeIntReply(1),
|
||||
reply.MakeStatusReply("OK"),
|
||||
reply.MakeErrReply("ERR unknown"),
|
||||
reply.MakeBulkReply([]byte("a\r\nb")), // test binary safe
|
||||
reply.MakeNullBulkReply(),
|
||||
reply.MakeMultiBulkReply([][]byte{
|
||||
protocol.MakeIntReply(1),
|
||||
protocol.MakeStatusReply("OK"),
|
||||
protocol.MakeErrReply("ERR unknown"),
|
||||
protocol.MakeBulkReply([]byte("a\r\nb")), // test binary safe
|
||||
protocol.MakeNullBulkReply(),
|
||||
protocol.MakeMultiBulkReply([][]byte{
|
||||
[]byte("a"),
|
||||
[]byte("\r\n"),
|
||||
}),
|
||||
reply.MakeEmptyMultiBulkReply(),
|
||||
protocol.MakeEmptyMultiBulkReply(),
|
||||
}
|
||||
for _, re := range replies {
|
||||
result, err := ParseOne(re.ToBytes())
|
||||
|
Reference in New Issue
Block a user