Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keys does not work when being mocked. #15

Open
freshteapot opened this issue Mar 24, 2020 · 1 comment
Open

Keys does not work when being mocked. #15

freshteapot opened this issue Mar 24, 2020 · 1 comment

Comments

@freshteapot
Copy link

freshteapot commented Mar 24, 2020

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)
}
@elliotchance
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants