Closed Littledarren closed 3 years ago
Under normal circumstances, do not use regular expressions for the key. It may cause errors. Examples of use are as follows:
db.HSet(ctx, "somekey", "field1", "value1", "field2", "value2")
mock.Regexp().ExpectHSet("somekey", "field1", `.*`, "field2", ".*").SetErr(errors.New("test error"))
In addition, you must set an error or return value, such as: Because for redis, it either has an error or returns the result correctly.
mock.Regexp().ExpectHSet("somekey", "field1", `.*`, "field2", ".*").SetErr(errors.New("test error"))
//OR
mock.Regexp().ExpectHSet("somekey", "field1", `.*`, "field2", ".*").SetVal(3)
Under normal circumstances, do not use regular expressions for the key. It may cause errors. Examples of use are as follows:
db.HSet(ctx, "somekey", "field1", "value1", "field2", "value2") mock.Regexp().ExpectHSet("somekey", "field1", `.*`, "field2", ".*").SetErr(errors.New("test error"))
In addition, you must set an error or return value, such as: Because for redis, it either has an error or returns the result correctly.
mock.Regexp().ExpectHSet("somekey", "field1", `.*`, "field2", ".*").SetErr(errors.New("test error")) //OR mock.Regexp().ExpectHSet("somekey", "field1", `.*`, "field2", ".*").SetVal(3)
Thanks. In short, it is not feasible to use regexp or custom match to match keys. Thanks for your help!
Sorry to take your precious time to help me.
problem codes
What I expect I want the two mock can fulfill all Hsets. No matter what I give them, they should return normally nil.
What I got
parameters do not match expectation '[somekey .*]', but call to cmd '[somekey field1 value1 field2 value2]'
I searched the Internet but found nothing about this two functions, I am not sure whether it is valid to use dot and star in the regexp. So help me please! Feel Free to comment.