Documentation
¶
Overview ¶
Package redistest provides a lightweight in-process Redis stub for unit tests.
Use New to start an in-process Redis server. The server is automatically stopped when the test completes.
srv := redistest.New(t)
client, err := redis.NewWithConfig(&redis.Config{
Addrs: []string{srv.Addr()},
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an in-process Redis stub backed by miniredis.Miniredis.
func New ¶
New starts an in-process Redis stub and registers tb.Cleanup to stop it when the test completes.
func (*Server) Addr ¶
Addr returns the network address (host:port) of the in-process server. Pass this as one of the entries in [redis.Config.Addrs]:
srv := redistest.New(t)
client, _ := redis.NewWithConfig(&redis.Config{Addrs: []string{srv.Addr()}})
func (*Server) Miniredis ¶
Miniredis returns the underlying *miniredis.Miniredis for fine-grained control in tests: setting key values directly, advancing the fake clock, or simulating connection failures via miniredis.Miniredis.SetError.