Feature: support for redis.Pool
Closed this issue · 3 comments
dbkaplun commented
My solution is to create a real redis.Pool
that returns a redigomock.Conn
:
mockRedisConn = redigomock.NewConn()
mockRedisPool = &redis.Pool{Dial: func () (redis.Conn, error) { return mockRedisConn, nil }}
rafaeljusto commented
That's a good solution, you could also use:
mockRedisConn := redigomock.NewConn()
// ...
mockRedisPool := redigo.NewPool(func() (Conn, error) {
return mockRedisConn, nil
}, 10)
dbkaplun commented
@rafaeljusto would you consider a PR with a MockPool for redis.Pool
?
rafaeljusto commented
Sure! PRs are always welcome! 😄
The problem that I see with redis.Pool
is that it is a struct
instead of an interface
, and this will make things more messy to mock. But if you have a good solution, please send a PR.