Documentation ¶
Index ¶
- Variables
- type BulkString
- type Command
- func (c *Command) Any() *Command
- func (c *Command) CloseConnection() *Command
- func (c *Command) Once() *Command
- func (c *Command) Times(n int) *Command
- func (c *Command) WillReturn(ret ...interface{}) *Command
- func (c *Command) WillReturnFn(r Result) *Command
- func (c *Command) WithAnyArgs() *Command
- func (c *Command) WithArgs(args ...string) *Command
- func (c *Command) WithDelay(d time.Duration) *Command
- func (c *Command) WithFnArgs(f func(...string) bool) *Command
- type Error
- type Result
- type Server
- func (s *Server) Addr() *net.TCPAddr
- func (s *Server) Expect(command string) *Command
- func (s *Server) ExpectBLPop(delay int, topic, resp string, result bool, keys ...string) *Command
- func (s *Server) ExpectBRPop(delay int, topic, resp string, result bool, keys ...string) *Command
- func (s *Server) ExpectGet(key string, exists bool, result string) *Command
- func (s *Server) ExpectHGetAll(key string, ret map[string]string) *Command
- func (s *Server) ExpectHSet(key, field, value string, update bool) *Command
- func (s *Server) ExpectLPush(result int, key string, values ...string) *Command
- func (s *Server) ExpectPing() *Command
- func (s *Server) ExpectQuit() *Command
- func (s *Server) ExpectRPush(result int, key string, values ...string) *Command
- func (s *Server) ExpectSet(key string, value string, success bool, extra ...string) *Command
- func (s *Server) ExpectationsWereMet() error
Constants ¶
This section is empty.
Variables ¶
ErrProtocol is the general error for unexpected input
Functions ¶
This section is empty.
Types ¶
type BulkString ¶
type BulkString string
BulkString is used to handle the bulk string, normal strings are treated as simple string
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command is a single
func (*Command) CloseConnection ¶
CloseConnection should close connection after this command
func (*Command) WillReturn ¶
WillReturn set the return value for this command
func (*Command) WillReturnFn ¶
WillReturnFn is a helper function for advance return value
func (*Command) WithAnyArgs ¶
WithAnyArgs if any argument is ok
func (*Command) WithArgs ¶
WithArgs add array as arguments
func (*Command) WithDelay ¶
WithDelay return command with delay
type Result ¶
type Result = func(...string) []interface{}
Result is the function that can be used for advanced result value
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the mock server used for handling the connections
func NewServer ¶
NewServer makes a server listening on addr. Close with .Close().
func (*Server) ExpectBLPop ¶
ExpectBLPop is the blpop command
func (*Server) ExpectBRPop ¶
ExpectBRPop is the brpop command
func (*Server) ExpectGet ¶
ExpectGet return a redis GET command
func (*Server) ExpectHGetAll ¶
ExpectHGetAll return the HGETALL command
func (*Server) ExpectHSet ¶
ExpectHSet is the command HSET, if the update is true, then it means the key was there already
func (*Server) ExpectLPush ¶
ExpectLPush is helper for lpush command
func (*Server) ExpectQuit ¶
ExpectQuit try to return quit command
func (*Server) ExpectRPush ¶
ExpectRPush is helper for lpush command
func (*Server) ExpectSet ¶
ExpectSet return a redis set command. success could be false only for NX or XX option, otherwise it dose not make sense