The request is later unpacked into a slice of arguments (which is native for Redis). But as it was passed as a map, the order every time is different.
Then in the mock.match function we iterate over the list of expected args and comparing it to the list of cmd args. This function accesses the elements by index, so chances of getting a match decrease with each new item added into the hash :smile:
In one of our applications, we are using
HSet
to create a Redis hash map. We've been using the map syntax:The request is later unpacked into a slice of arguments (which is native for Redis). But as it was passed as a map, the order every time is different. Then in the mock.match function we iterate over the list of expected args and comparing it to the list of cmd args. This function accesses the elements by index, so chances of getting a match decrease with each new item added into the hash :smile:
Workaround: Use the slice syntax instead:
It is more confusing but works :slightly_smiling_face:
I'm not really sure what could be a good approach to handle this :confused: Possible solutions on my mind:
mock.MatchExpectationsInOrder(true)
optionmatch
function to ignore an order of the pairs if the called operation supports map syntax