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

Regexp is not applying on the key #65

Open
rinormaloku opened this issue Mar 23, 2023 · 2 comments
Open

Regexp is not applying on the key #65

rinormaloku opened this issue Mar 23, 2023 · 2 comments

Comments

@rinormaloku
Copy link

Regexp applies only on the value. But there are cases where the key is generated and we need to match it as well.

This code works:

mockClient.Regexp().ExpectMSet("key", ".*").SetVal("OKX")
result := client.MSet(ctx, "key", "value")	

This code doesn't work:

mockClient.Regexp().ExpectMSet(".*", "value").SetVal("OKX")
result := client.MSet(ctx, "key", "value")
@monkey92t
Copy link
Member

clientMock.Regexp().ExpectSet(".*", ".*", 1*time.Second).SetVal("regexp set val")
set = client.Set(ctx, "rand_key", "rand_value", 1*time.Second)
Expect(set.Err()).NotTo(HaveOccurred())
Expect(set.Val()).To(Equal("regexp set val"))

After testing, it can work normally.

@javking07
Copy link

clientMock.Regexp().ExpectSet(".*", ".*", 1*time.Second).SetVal("regexp set val")
set = client.Set(ctx, "rand_key", "rand_value", 1*time.Second)
Expect(set.Err()).NotTo(HaveOccurred())
Expect(set.Val()).To(Equal("regexp set val"))

After testing, it can work normally.

Ran into this gotcha myself. Any way this info could be integrated into the package documentation?

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

3 participants