redismock
redismock copied to clipboard
Keys does not work when being mocked.
Using redisMock.On("Keys", "hello") fails and doesnt acknowledge the pattern sent in.
When I use "MatchedBy", it reports it as missing.
redisClient.On("Keys", mock.MatchedBy(func(input string) bool {
fmt.Println(input)
return true
}))
When I use mock.Anything, it works.
Code for Keys doesnt send the pattern on to the Called. Below works.
func (m *ClientMock) Keys(pattern string) *redis.StringSliceCmd {
if !m.hasStub("Keys") {
return m.client.Keys(pattern)
}
return m.Called(pattern).Get(0).(*redis.StringSliceCmd)
}
Ah yes, this is a bug. If you have already fixed it please put in the PR.