elliotchance / redismock

🕋 Mocking Redis in unit tests in Go.
MIT License
147 stars 24 forks source link

Missing ScanType Method #37

Closed Jared-Prime closed 3 years ago

Jared-Prime commented 3 years ago

Using github.com/go-redis/redis/v8 v8.4.4, I get the following error

Cannot use 'mock' (type *redismock.ClientMock) as type redis.Cmdable Type does not implement 'redis.Cmdable' as some methods are missing: ScanType(ctx context.Context, cursor uint64, match string, count int64, keyType string) *ScanCmd
elliotchance commented 3 years ago

go-redis is constantly adding new methods to the interface. Feel free to submit a PR. However, this has happened enough times now that it's probably better having the mock encapsulate the interface, like:

type ClientMock struct {
    mock.Mock
    redis.Cmdable
    client *redis.Client
}

At least this way new interface methods will result in a panic only if they are used, and not constantly break existing code like it does now.

lilien1010 commented 3 years ago

also having the same issues.

auth/xxx.go:36:47: cannot use redisMock (type *redismock.ClientMock) as type redis.Cmdable in argument to auth.NewRedisTokenFetcher:
    *redismock.ClientMock does not implement redis.Cmdable (missing ScanType method)
Jared-Prime commented 3 years ago

thanks @lilien1010 -- I appreciate you putting in the commit. Apologies for not doing it sooner