tsuru: github.com/albertoleal/tsuru/testing/redis Index | Files

package redis

import "github.com/albertoleal/tsuru/testing/redis"

Index

Package Files

redis.go

func ClearRedisKeys Uses

func ClearRedisKeys(keysPattern string, c *gocheck.C)

type CmdType Uses

type CmdType byte

CmdType represents a type of command, it may be a send or a do.

const (
    // CmdSend represents a send call in redigo.
    CmdSend CmdType = iota
    // CmdDo represents a do call in redigo.
    CmdDo
)

type FailingFakeRedisConn Uses

type FailingFakeRedisConn struct {
    FakeRedisConn
}

FailingFakeRedisConn is a fake connection that fails to execute commands (via Do and/or Send).

func (*FailingFakeRedisConn) Do Uses

func (c *FailingFakeRedisConn) Do(cmd string, args ...interface{}) (interface{}, error)

func (*FailingFakeRedisConn) Send Uses

func (c *FailingFakeRedisConn) Send(cmd string, args ...interface{}) error

type FakeRedisConn Uses

type FakeRedisConn struct {
    Cmds []RedisCommand
    // contains filtered or unexported fields
}

FakeRedisConn is a fake implementation of redis.Conn.

It's useful for mocks only. You may use it with a pool:

fakePool := redis.NewPool(func() (redis.Conn, error) {
    return &FakeRedisConn{}, nil
}, 10)
conn := fakePool.Get()

func (*FakeRedisConn) Close Uses

func (c *FakeRedisConn) Close() error

Close closes the connection.

func (*FakeRedisConn) Do Uses

func (c *FakeRedisConn) Do(cmd string, args ...interface{}) (interface{}, error)

Do executes a do command, storing the arguments in the internal slice of commands. It doesn't return anything.

func (*FakeRedisConn) Err Uses

func (c *FakeRedisConn) Err() error

Err returns the last error.

func (*FakeRedisConn) Flush Uses

func (*FakeRedisConn) Flush() error

Flush does not do anything in the fake connection.

func (*FakeRedisConn) GetCommands Uses

func (c *FakeRedisConn) GetCommands(tp CmdType) []RedisCommand

GetCommands return the list of commands of the given type.

func (*FakeRedisConn) Receive Uses

func (*FakeRedisConn) Receive() (interface{}, error)

Receive does not do anything in the fake connection.

func (*FakeRedisConn) Send Uses

func (c *FakeRedisConn) Send(cmd string, args ...interface{}) error

Send executes a send command, storing the arguments in the internal slice of commands. It doesn't return anything.

type RedisCommand Uses

type RedisCommand struct {
    Cmd  string
    Args []interface{}
    Type CmdType
}

RedisCommand is a command sent to the redis server.

type ResultCommandRedisConn Uses

type ResultCommandRedisConn struct {
    *FakeRedisConn
    Reply        map[string]interface{}
    DefaultReply interface{}
}

ResultCommandRedisConn is a fake connection that returns a result in the Do command.

func (*ResultCommandRedisConn) Do Uses

func (c *ResultCommandRedisConn) Do(cmd string, args ...interface{}) (interface{}, error)

Do returns the result for a command as specified by the Reply map. If no command is provided, it will return DefaultReply.

Package redis imports 4 packages (graph). Updated 2016-07-28. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).