ConnWithTimeout support
Closed this issue · 2 comments
terashi58 commented
When I use redis.DoWithTimeout
on my code, I get redis: connection does not support ConnWithTimeout
error on tests with the redigomock.Conn
.
I can implement the redis.ConnWithTimeout
interface by wrapping the mock like:
type wrapConn struct {
*redigomock.Conn
}
func (c wrapConn) DoWithTimeout(timeout time.Duration, cmd string, args ...interface{}) (interface{}, error) {
return c.Conn.Do(cmd, args...)
}
func (c wrapConn) ReceiveWithTimeout(timeout time.Duration) (interface{}, error) {
return c.Conn.Receive()
}
It works well, but considering all redis.Conn
implementations in the redigo package support the redis.ConnWithTimeout
interface, it would be nice if redigomock.Conn
also support it by itself.
I believe simply ignoring the timeout argument like above is enough, since we can mock a timeout error with ExpectError
.
Any thoughts?
rafaeljusto commented
Hey @terashi58 , sorry for the delay. Yeah, we should update the mock to satisfy that interface. Will have a look this weekend. 👍
terashi58 commented
Thanks for your quick improvement!