rename godis/redis/reply to godis/redis/protocol

This commit is contained in:
hdt3213
2022-04-10 08:35:51 +08:00
parent c97f3aae6e
commit 37ef7d8a34
55 changed files with 774 additions and 774 deletions

View File

@@ -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())