You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that when I try to match a request body that is an array, the requests are still matching even though the mock and request body are clearly different.
On the code, before getting into the lines where the json.Unmarshal is called, I've noticed that the matcher already returns true in the regexp.MatchString part.
I've tried to come-up with a fix, but it seems that it's gonna be difficult without knowing whether the request body contains regular expressions or just a normal JSON.
The text was updated successfully, but these errors were encountered:
bodyStr has value of {"data": {"a": "b"}} matchStr has a value of {"a": "b"}
This sadly makes the request match, and thus makes some of my tests pass although they should fail with an unmatched request error :(
I would suggest to not match the body by regex, at all, unless the user really wants to (maybe we can create a method for that, like MatchBodyRegex or similar.
Having a MatchBody method that sneakly does regex matching is error prone and can cause huge issues, especially in such an important mocking library.
First, thank you for making this amazing project!
I've noticed that when I try to match a request body that is an array, the requests are still matching even though the mock and request body are clearly different.
On the code, before getting into the lines where the
json.Unmarshal
is called, I've noticed that the matcher already returns true in theregexp.MatchString
part.I've tried to come-up with a fix, but it seems that it's gonna be difficult without knowing whether the request body contains regular expressions or just a normal JSON.
The text was updated successfully, but these errors were encountered: