mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-21 15:09:30 +08:00
Removed logic to get unexported methods from the echovault package in all tests.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -50,8 +50,7 @@ import (
|
|||||||
|
|
||||||
type EchoVault struct {
|
type EchoVault struct {
|
||||||
// clock is an implementation of a time interface that allows mocking of time functions during testing.
|
// clock is an implementation of a time interface that allows mocking of time functions during testing.
|
||||||
clock clock.Clock
|
clock clock.Clock
|
||||||
getClock func() clock.Clock
|
|
||||||
|
|
||||||
// config holds the echovault configuration variables.
|
// config holds the echovault configuration variables.
|
||||||
config config.Config
|
config config.Config
|
||||||
@@ -69,7 +68,7 @@ type EchoVault struct {
|
|||||||
rwMutex sync.RWMutex // Mutex as only one process should be able to update this list at a time.
|
rwMutex sync.RWMutex // Mutex as only one process should be able to update this list at a time.
|
||||||
keys []string // string slice of the volatile keys
|
keys []string // string slice of the volatile keys
|
||||||
}
|
}
|
||||||
// LFU cache used when eviction policy is allkeys-lfu or volatile-lfu
|
// LFU cache used when eviction policy is allkeys-lfu or volatile-lfu.
|
||||||
lfuCache struct {
|
lfuCache struct {
|
||||||
mutex sync.Mutex // Mutex as only one goroutine can edit the LFU cache at a time.
|
mutex sync.Mutex // Mutex as only one goroutine can edit the LFU cache at a time.
|
||||||
cache eviction.CacheLFU // LFU cache represented by a min head.
|
cache eviction.CacheLFU // LFU cache represented by a min head.
|
||||||
@@ -83,7 +82,6 @@ type EchoVault struct {
|
|||||||
// Holds the list of all commands supported by the echovault.
|
// Holds the list of all commands supported by the echovault.
|
||||||
commandsRWMut sync.RWMutex
|
commandsRWMut sync.RWMutex
|
||||||
commands []internal.Command
|
commands []internal.Command
|
||||||
getCommands func() []internal.Command
|
|
||||||
|
|
||||||
raft *raft.Raft // The raft replication layer for the echovault.
|
raft *raft.Raft // The raft replication layer for the echovault.
|
||||||
memberList *memberlist.MemberList // The memberlist layer for the echovault.
|
memberList *memberlist.MemberList // The memberlist layer for the echovault.
|
||||||
@@ -91,10 +89,7 @@ type EchoVault struct {
|
|||||||
context context.Context
|
context context.Context
|
||||||
|
|
||||||
acl *acl.ACL
|
acl *acl.ACL
|
||||||
getACL func() interface{}
|
pubSub *pubsub.PubSub
|
||||||
|
|
||||||
pubSub *pubsub.PubSub
|
|
||||||
getPubSub func() interface{}
|
|
||||||
|
|
||||||
snapshotInProgress atomic.Bool // Atomic boolean that's true when actively taking a snapshot.
|
snapshotInProgress atomic.Bool // Atomic boolean that's true when actively taking a snapshot.
|
||||||
rewriteAOFInProgress atomic.Bool // Atomic boolean that's true when actively rewriting AOF file is in progress.
|
rewriteAOFInProgress atomic.Bool // Atomic boolean that's true when actively rewriting AOF file is in progress.
|
||||||
@@ -167,27 +162,11 @@ func NewEchoVault(options ...func(echovault *EchoVault)) (*EchoVault, error) {
|
|||||||
log.Printf("loaded plugin %s\n", path)
|
log.Printf("loaded plugin %s\n", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function for server commands retrieval
|
|
||||||
echovault.getCommands = func() []internal.Command {
|
|
||||||
return echovault.commands
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function for clock retrieval
|
|
||||||
echovault.getClock = func() clock.Clock {
|
|
||||||
return echovault.clock
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up ACL module
|
// Set up ACL module
|
||||||
echovault.acl = acl.NewACL(echovault.config)
|
echovault.acl = acl.NewACL(echovault.config)
|
||||||
echovault.getACL = func() interface{} {
|
|
||||||
return echovault.acl
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up Pub/Sub module
|
// Set up Pub/Sub module
|
||||||
echovault.pubSub = pubsub.NewPubSub()
|
echovault.pubSub = pubsub.NewPubSub()
|
||||||
echovault.getPubSub = func() interface{} {
|
|
||||||
return echovault.pubSub
|
|
||||||
}
|
|
||||||
|
|
||||||
if echovault.isInCluster() {
|
if echovault.isInCluster() {
|
||||||
echovault.raft = raft.NewRaft(raft.Opts{
|
echovault.raft = raft.NewRaft(raft.Opts{
|
||||||
|
@@ -154,12 +154,6 @@ func makeCluster(size int) ([]ClientServerPair, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not open tcp connection: %v", err)
|
return nil, fmt.Errorf("could not open tcp connection: %v", err)
|
||||||
}
|
}
|
||||||
for {
|
|
||||||
// Wait until connection is no longer nil.
|
|
||||||
if conn != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
pairs[i] = ClientServerPair{
|
pairs[i] = ClientServerPair{
|
||||||
@@ -502,13 +496,6 @@ func Test_TLS(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
|
||||||
// Break out when the connection is no longer nil.
|
|
||||||
if conn != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
// Test that we can set and get a value from the server.
|
// Test that we can set and get a value from the server.
|
||||||
@@ -624,13 +611,7 @@ func Test_MTLS(t *testing.T) {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
return
|
||||||
|
|
||||||
for {
|
|
||||||
// Break out when the connection is no longer nil.
|
|
||||||
if conn != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
@@ -19,6 +19,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/echovault/echovault/internal"
|
"github.com/echovault/echovault/internal"
|
||||||
|
"github.com/echovault/echovault/internal/clock"
|
||||||
"github.com/echovault/echovault/internal/constants"
|
"github.com/echovault/echovault/internal/constants"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -51,10 +52,10 @@ func (server *EchoVault) getHandlerFuncParams(ctx context.Context, cmd []string,
|
|||||||
LoadModule: server.LoadModule,
|
LoadModule: server.LoadModule,
|
||||||
UnloadModule: server.UnloadModule,
|
UnloadModule: server.UnloadModule,
|
||||||
ListModules: server.ListModules,
|
ListModules: server.ListModules,
|
||||||
GetClock: server.getClock,
|
|
||||||
GetPubSub: server.getPubSub,
|
GetPubSub: server.getPubSub,
|
||||||
GetACL: server.getACL,
|
GetACL: server.getACL,
|
||||||
GetAllCommands: server.getCommands,
|
GetAllCommands: server.getCommands,
|
||||||
|
GetClock: server.getClock,
|
||||||
DeleteKey: func(key string) error {
|
DeleteKey: func(key string) error {
|
||||||
server.storeLock.Lock()
|
server.storeLock.Lock()
|
||||||
defer server.storeLock.Unlock()
|
defer server.storeLock.Unlock()
|
||||||
@@ -142,3 +143,19 @@ func (server *EchoVault) handleCommand(ctx context.Context, message []byte, conn
|
|||||||
|
|
||||||
return nil, errors.New("not cluster leader, cannot carry out command")
|
return nil, errors.New("not cluster leader, cannot carry out command")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (server *EchoVault) getCommands() []internal.Command {
|
||||||
|
return server.commands
|
||||||
|
}
|
||||||
|
|
||||||
|
func (server *EchoVault) getACL() interface{} {
|
||||||
|
return server.acl
|
||||||
|
}
|
||||||
|
|
||||||
|
func (server *EchoVault) getPubSub() interface{} {
|
||||||
|
return server.pubSub
|
||||||
|
}
|
||||||
|
|
||||||
|
func (server *EchoVault) getClock() clock.Clock {
|
||||||
|
return server.clock
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,6 @@
|
|||||||
package admin_test
|
package admin_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/echovault/echovault/echovault"
|
"github.com/echovault/echovault/echovault"
|
||||||
@@ -36,12 +34,10 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"reflect"
|
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupServer(port uint16) (*echovault.EchoVault, error) {
|
func setupServer(port uint16) (*echovault.EchoVault, error) {
|
||||||
@@ -53,45 +49,7 @@ func setupServer(port uint16) (*echovault.EchoVault, error) {
|
|||||||
return echovault.NewEchoVault(echovault.WithConfig(cfg))
|
return echovault.NewEchoVault(echovault.WithConfig(cfg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUnexportedField(field reflect.Value) interface{} {
|
func Test_AdminCommands(t *testing.T) {
|
||||||
return reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())).Elem().Interface()
|
|
||||||
}
|
|
||||||
|
|
||||||
func getHandler(mockServer *echovault.EchoVault, commands ...string) internal.HandlerFunc {
|
|
||||||
if len(commands) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
getCommands :=
|
|
||||||
getUnexportedField(reflect.ValueOf(mockServer).Elem().FieldByName("getCommands")).(func() []internal.Command)
|
|
||||||
for _, c := range getCommands() {
|
|
||||||
if strings.EqualFold(commands[0], c.Command) && len(commands) == 1 {
|
|
||||||
// Get command handler
|
|
||||||
return c.HandlerFunc
|
|
||||||
}
|
|
||||||
if strings.EqualFold(commands[0], c.Command) {
|
|
||||||
// Get sub-command handler
|
|
||||||
for _, sc := range c.SubCommands {
|
|
||||||
if strings.EqualFold(commands[1], sc.Command) {
|
|
||||||
return sc.HandlerFunc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getHandlerFuncParams(ctx context.Context, mockServer *echovault.EchoVault, cmd []string, conn *net.Conn) internal.HandlerFuncParams {
|
|
||||||
getCommands :=
|
|
||||||
getUnexportedField(reflect.ValueOf(mockServer).Elem().FieldByName("getCommands")).(func() []internal.Command)
|
|
||||||
return internal.HandlerFuncParams{
|
|
||||||
Context: ctx,
|
|
||||||
Command: cmd,
|
|
||||||
Connection: conn,
|
|
||||||
GetAllCommands: getCommands,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_AdminCommand(t *testing.T) {
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
_ = os.RemoveAll("./testdata")
|
_ = os.RemoveAll("./testdata")
|
||||||
})
|
})
|
||||||
@@ -104,23 +62,37 @@ func Test_AdminCommand(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mockServer, err := setupServer(uint16(port))
|
mockServer, err := setupServer(uint16(port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := getHandler(mockServer, "COMMANDS")(
|
wg := sync.WaitGroup{}
|
||||||
getHandlerFuncParams(context.Background(), mockServer, []string{"commands"}, nil),
|
wg.Add(1)
|
||||||
)
|
go func() {
|
||||||
|
wg.Done()
|
||||||
|
mockServer.Start()
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
if err = client.WriteArray([]resp.Value{resp.StringValue("COMMANDS")}); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rd := resp.NewReader(bytes.NewReader(res))
|
res, _, err := client.ReadValue()
|
||||||
rv, _, err := rd.ReadValue()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all the commands from the existing modules.
|
// Get all the commands from the existing modules.
|
||||||
@@ -148,8 +120,8 @@ func Test_AdminCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(allCommands) != len(rv.Array()) {
|
if len(allCommands) != len(res.Array()) {
|
||||||
t.Errorf("expected commands list to be of length %d, got %d", len(allCommands), len(rv.Array()))
|
t.Errorf("expected commands list to be of length %d, got %d", len(allCommands), len(res.Array()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -161,23 +133,37 @@ func Test_AdminCommand(t *testing.T) {
|
|||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mockServer, err := setupServer(uint16(port))
|
mockServer, err := setupServer(uint16(port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := getHandler(mockServer, "COMMAND", "COUNT")(
|
wg := sync.WaitGroup{}
|
||||||
getHandlerFuncParams(context.Background(), mockServer, []string{"command", "count"}, nil),
|
wg.Add(1)
|
||||||
)
|
go func() {
|
||||||
|
wg.Done()
|
||||||
|
mockServer.Start()
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
if err = client.WriteArray([]resp.Value{resp.StringValue("COMMAND"), resp.StringValue("COUNT")}); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rd := resp.NewReader(bytes.NewReader(res))
|
res, _, err := client.ReadValue()
|
||||||
rv, _, err := rd.ReadValue()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all the commands from the existing modules.
|
// Get all the commands from the existing modules.
|
||||||
@@ -205,8 +191,8 @@ func Test_AdminCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(allCommands) != rv.Integer() {
|
if len(allCommands) != res.Integer() {
|
||||||
t.Errorf("expected COMMAND COUNT to return %d, got %d", len(allCommands), rv.Integer())
|
t.Errorf("expected COMMAND COUNT to return %d, got %d", len(allCommands), res.Integer())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -225,6 +211,21 @@ func Test_AdminCommand(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
wg.Done()
|
||||||
|
mockServer.Start()
|
||||||
|
}()
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
// Get all the commands from the existing modules.
|
// Get all the commands from the existing modules.
|
||||||
var allCommands []internal.Command
|
var allCommands []internal.Command
|
||||||
allCommands = append(allCommands, acl.Commands()...)
|
allCommands = append(allCommands, acl.Commands()...)
|
||||||
@@ -305,24 +306,26 @@ func Test_AdminCommand(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
res, err := getHandler(mockServer, test.cmd...)(
|
command := make([]resp.Value, len(test.cmd))
|
||||||
getHandlerFuncParams(context.Background(), mockServer, test.cmd, nil),
|
for i, c := range test.cmd {
|
||||||
)
|
command[i] = resp.StringValue(c)
|
||||||
|
}
|
||||||
|
if err = client.WriteArray(command); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res, _, err := client.ReadValue()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
rd := resp.NewReader(bytes.NewReader(res))
|
if len(res.Array()) != len(test.want) {
|
||||||
rv, _, err := rd.ReadValue()
|
t.Errorf("expected response of length %d, got %d", len(test.want), len(res.Array()))
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rv.Array()) != len(test.want) {
|
for _, command := range res.Array() {
|
||||||
t.Errorf("expected response of length %d, got %d", len(test.want), len(rv.Array()))
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, command := range rv.Array() {
|
|
||||||
if !slices.ContainsFunc(test.want, func(c string) bool {
|
if !slices.ContainsFunc(test.want, func(c string) bool {
|
||||||
return strings.EqualFold(c, command.String())
|
return strings.EqualFold(c, command.String())
|
||||||
}) {
|
}) {
|
||||||
@@ -441,6 +444,7 @@ func Test_AdminCommand(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
respConn := resp.NewConn(conn)
|
respConn := resp.NewConn(conn)
|
||||||
|
@@ -15,110 +15,96 @@
|
|||||||
package connection_test
|
package connection_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"context"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"github.com/echovault/echovault/echovault"
|
"github.com/echovault/echovault/echovault"
|
||||||
"github.com/echovault/echovault/internal"
|
"github.com/echovault/echovault/internal"
|
||||||
"github.com/echovault/echovault/internal/config"
|
"github.com/echovault/echovault/internal/config"
|
||||||
"github.com/echovault/echovault/internal/constants"
|
"github.com/echovault/echovault/internal/constants"
|
||||||
"github.com/tidwall/resp"
|
"github.com/tidwall/resp"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var mockServer *echovault.EchoVault
|
var mockServer *echovault.EchoVault
|
||||||
|
var port int
|
||||||
|
var addr = "localhost"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
port, _ = internal.GetFreePort()
|
||||||
mockServer, _ = echovault.NewEchoVault(
|
mockServer, _ = echovault.NewEchoVault(
|
||||||
echovault.WithConfig(config.Config{
|
echovault.WithConfig(config.Config{
|
||||||
DataDir: "",
|
DataDir: "",
|
||||||
EvictionPolicy: constants.NoEviction,
|
EvictionPolicy: constants.NoEviction,
|
||||||
|
BindAddr: addr,
|
||||||
|
Port: uint16(port),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
wg := sync.WaitGroup{}
|
||||||
|
wg.Add(1)
|
||||||
func getUnexportedField(field reflect.Value) interface{} {
|
go func() {
|
||||||
return reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())).Elem().Interface()
|
wg.Done()
|
||||||
}
|
mockServer.Start()
|
||||||
|
}()
|
||||||
func getHandler(commands ...string) internal.HandlerFunc {
|
wg.Wait()
|
||||||
if len(commands) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
getCommands :=
|
|
||||||
getUnexportedField(reflect.ValueOf(mockServer).Elem().FieldByName("getCommands")).(func() []internal.Command)
|
|
||||||
for _, c := range getCommands() {
|
|
||||||
if strings.EqualFold(commands[0], c.Command) && len(commands) == 1 {
|
|
||||||
// Get command handler
|
|
||||||
return c.HandlerFunc
|
|
||||||
}
|
|
||||||
if strings.EqualFold(commands[0], c.Command) {
|
|
||||||
// Get sub-command handler
|
|
||||||
for _, sc := range c.SubCommands {
|
|
||||||
if strings.EqualFold(commands[1], sc.Command) {
|
|
||||||
return sc.HandlerFunc
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getHandlerFuncParams(ctx context.Context, cmd []string, conn *net.Conn) internal.HandlerFuncParams {
|
|
||||||
return internal.HandlerFuncParams{
|
|
||||||
Context: ctx,
|
|
||||||
Command: cmd,
|
|
||||||
Connection: conn,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_HandlePing(t *testing.T) {
|
func Test_HandlePing(t *testing.T) {
|
||||||
ctx := context.Background()
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
command []string
|
command []resp.Value
|
||||||
expected string
|
expected string
|
||||||
expectedErr error
|
expectedErr error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
command: []string{"PING"},
|
command: []resp.Value{resp.StringValue("PING")},
|
||||||
expected: "PONG",
|
expected: "PONG",
|
||||||
expectedErr: nil,
|
expectedErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: []string{"PING", "Hello, world!"},
|
command: []resp.Value{resp.StringValue("PING"), resp.StringValue("Hello, world!")},
|
||||||
expected: "Hello, world!",
|
expected: "Hello, world!",
|
||||||
expectedErr: nil,
|
expectedErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
command: []string{"PING", "Hello, world!", "Once more"},
|
command: []resp.Value{
|
||||||
|
resp.StringValue("PING"),
|
||||||
|
resp.StringValue("Hello, world!"),
|
||||||
|
resp.StringValue("Once more"),
|
||||||
|
},
|
||||||
expected: "",
|
expected: "",
|
||||||
expectedErr: errors.New(constants.WrongArgsResponse),
|
expectedErr: errors.New(constants.WrongArgsResponse),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
res, err := getHandler("PING")(getHandlerFuncParams(ctx, test.command, nil))
|
if err = client.WriteArray(test.command); err != nil {
|
||||||
if test.expectedErr != nil && err != nil {
|
t.Error(err)
|
||||||
if err.Error() != test.expectedErr.Error() {
|
return
|
||||||
t.Errorf("expected error %s, got: %s", test.expectedErr.Error(), err.Error())
|
}
|
||||||
|
|
||||||
|
res, _, err := client.ReadValue()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if test.expectedErr != nil {
|
||||||
|
if !strings.Contains(res.Error().Error(), test.expectedErr.Error()) {
|
||||||
|
t.Errorf("expected error \"%s\", got \"%s\"", test.expectedErr.Error(), res.Error().Error())
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
if res.String() != test.expected {
|
||||||
}
|
t.Errorf("expected response \"%s\", got \"%s\"", test.expected, res.String())
|
||||||
rd := resp.NewReader(bytes.NewBuffer(res))
|
|
||||||
v, _, err := rd.ReadValue()
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
if v.String() != test.expected {
|
|
||||||
t.Errorf("expected %s, got: %s", test.expected, v.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -64,6 +64,7 @@ func Test_HandleSET(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -464,6 +465,7 @@ func Test_HandleMSET(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -551,6 +553,7 @@ func Test_HandleGET(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -665,6 +668,7 @@ func Test_HandleMGET(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -767,6 +771,7 @@ func Test_HandleDEL(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -874,6 +879,7 @@ func Test_HandlePERSIST(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1026,6 +1032,7 @@ func Test_HandleEXPIRETIME(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1142,6 +1149,7 @@ func Test_HandleTTL(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1258,6 +1266,7 @@ func Test_HandleEXPIRE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1540,6 +1549,7 @@ func Test_HandleEXPIREAT(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
@@ -57,6 +57,7 @@ func Test_HandleHSET(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -236,6 +237,7 @@ func Test_HandleHINCRBY(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -433,6 +435,7 @@ func Test_HandleHGET(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -584,6 +587,7 @@ func Test_HandleHSTRLEN(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -737,6 +741,7 @@ func Test_HandleHVALS(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -874,6 +879,7 @@ func Test_HandleHRANDFIELD(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1078,6 +1084,7 @@ func Test_HandleHLEN(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1199,6 +1206,7 @@ func Test_HandleHKeys(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1322,6 +1330,7 @@ func Test_HandleHGETALL(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1458,6 +1467,7 @@ func Test_HandleHEXISTS(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1580,6 +1590,7 @@ func Test_HandleHDEL(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
@@ -57,6 +57,7 @@ func Test_HandleLLEN(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -176,6 +177,7 @@ func Test_HandleLINDEX(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -335,6 +337,7 @@ func Test_HandleLRANGE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -519,6 +522,7 @@ func Test_HandleLSET(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -703,6 +707,7 @@ func Test_HandleLTRIM(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -898,6 +903,7 @@ func Test_HandleLREM(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1058,6 +1064,7 @@ func Test_HandleLMOVE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1284,6 +1291,7 @@ func Test_HandleLPUSH(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1434,6 +1442,7 @@ func Test_HandleRPUSH(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1584,6 +1593,7 @@ func Test_HandlePOP(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,7 @@ func Test_HandleSADD(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -201,6 +202,7 @@ func Test_HandleSCARD(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -323,6 +325,7 @@ func Test_HandleSDIFF(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -468,6 +471,7 @@ func Test_HandleSDIFFSTORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -645,6 +649,7 @@ func Test_HandleSINTER(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -790,6 +795,7 @@ func Test_HandleSINTERCARD(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -940,6 +946,7 @@ func Test_HandleSINTERSTORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1117,6 +1124,7 @@ func Test_HandleSISMEMBER(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1234,6 +1242,7 @@ func Test_HandleSMEMBERS(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1356,6 +1365,7 @@ func Test_HandleSMISMEMBER(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1478,6 +1488,7 @@ func Test_HandleSMOVE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1669,6 +1680,7 @@ func Test_HandleSPOP(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1806,6 +1818,7 @@ func Test_HandleSRANDMEMBER(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1966,6 +1979,7 @@ func Test_HandleSREM(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2102,6 +2116,7 @@ func Test_HandleSUNION(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2240,6 +2255,7 @@ func Test_HandleSUNIONSTORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
@@ -59,6 +59,7 @@ func Test_HandleZADD(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -270,6 +271,7 @@ func Test_HandleZCARD(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -396,6 +398,7 @@ func Test_HandleZCOUNT(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -566,6 +569,7 @@ func Test_HandleZLEXCOUNT(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -712,6 +716,7 @@ func Test_HandleZDIFF(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -927,6 +932,7 @@ func Test_HandleZDIFFSTORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1165,6 +1171,7 @@ func Test_HandleZINCRBY(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1443,6 +1450,7 @@ func Test_HandleZMPOP(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -1753,6 +1761,7 @@ func Test_HandleZPOP(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2009,6 +2018,7 @@ func Test_HandleZMSCORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2132,6 +2142,7 @@ func Test_HandleZSCORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2264,6 +2275,7 @@ func Test_HandleZRANDMEMBER(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2456,6 +2468,7 @@ func Test_HandleZRANK(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2608,6 +2621,7 @@ func Test_HandleZREM(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2776,6 +2790,7 @@ func Test_HandleZREMRANGEBYSCORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -2947,6 +2962,7 @@ func Test_HandleZREMRANGEBYRANK(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -3172,6 +3188,7 @@ func Test_HandleZREMRANGEBYLEX(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -3368,6 +3385,7 @@ func Test_HandleZRANGE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -3664,6 +3682,7 @@ func Test_HandleZRANGESTORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -4010,6 +4029,7 @@ func Test_HandleZINTER(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -4373,6 +4393,7 @@ func Test_HandleZINTERSTORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -4783,6 +4804,7 @@ func Test_HandleZUNION(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
@@ -5171,6 +5193,7 @@ func Test_HandleZUNIONSTORE(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error()
|
t.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
@@ -56,6 +56,7 @@ func Test_HandleSetRange(t *testing.T) {
|
|||||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", addr, port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
client := resp.NewConn(conn)
|
client := resp.NewConn(conn)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user