redismock icon indicating copy to clipboard operation
redismock copied to clipboard

Keys does not work when being mocked.

Open freshteapot opened this issue 4 years ago • 1 comments

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

freshteapot avatar Mar 24 '20 16:03 freshteapot

Ah yes, this is a bug. If you have already fixed it please put in the PR.

elliotchance avatar Mar 28 '20 22:03 elliotchance