rafaeljusto/redigomock

Feature: support for redis.Pool

Closed this issue · 3 comments

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 }}

That's a good solution, you could also use:

mockRedisConn := redigomock.NewConn()
// ...
mockRedisPool := redigo.NewPool(func() (Conn, error) {
  return mockRedisConn, nil
}, 10)

@rafaeljusto would you consider a PR with a MockPool for redis.Pool?

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.