-
Notifications
You must be signed in to change notification settings - Fork 103
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
Or()
and And()
don't work correctly
#145
Comments
maxatome
added a commit
that referenced
this issue
Jul 20, 2023
Both "rearm" the body before (re-)reading it, so they can be used several times in a same matcher (combined with Or & And). Closes #145. Signed-off-by: Maxime Soulé <[email protected]>
Hi, good catch ! #146 should fix it. Could you test and tell us, please? |
maxatome
added a commit
that referenced
this issue
Jul 20, 2023
Both "rearm" the body before (re-)reading it, so they can be used several times in a same matcher (combined with Or & And). Closes #145. Signed-off-by: Maxime Soulé <[email protected]>
Just as a note, do you know tdhttpmock? it allows you to match JSON content very easily, as it seems it is your case here: httpmock.RegisterMatcherResponder(
http.MethodPost,
"/test",
tdhttpmock.JSONBody(td.Any(
td.SuperJSONOf(`{"subject":"incorrect"}`),
td.SuperJSONOf(`{"scenario":"incorrect"}`),
)) See Any and SuperJSONOf doc. Or if you don't care the JSON is correct, but using regexp: tdhttpmock.Body(td.Re(`"(subject|scenario)":"incorrect"`)) See Re doc. |
maxatome
added a commit
that referenced
this issue
Jul 24, 2023
Both "rearm" the body before (re-)reading it, so they can be used several times in a same matcher (combined with Or & And). At the same time, simplify the body copy and make the "rearming" more performant. Closes #145. Signed-off-by: Maxime Soulé <[email protected]>
maxatome
added a commit
that referenced
this issue
Jul 24, 2023
Both "rearm" the body before (re-)reading it, so they can be used several times in a same matcher (combined with Or & And). At the same time, simplify the body copy and make the "rearming" more performant. Closes #145. Signed-off-by: Maxime Soulé <[email protected]>
maxatome
added a commit
that referenced
this issue
Aug 16, 2023
Both "rearm" the body before (re-)reading it, so they can be used several times in a same matcher (combined with Or & And). At the same time, simplify the body copy and make the "rearming" more performant. Closes #145. Signed-off-by: Maxime Soulé <[email protected]>
maxatome
added a commit
that referenced
this issue
Aug 16, 2023
Both "rearm" the body before (re-)reading it, so they can be used several times in a same matcher (combined with Or & And). At the same time, simplify the body copy and make the "rearming" more performant. Closes #145. Signed-off-by: Maxime Soulé <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! Today I've tried to make
Matcher
usingOr
:and figured out that in 100% of cases, the first matcher was working correctly, but the second one, which was called in
Or()
function, was ignored. I suppose there is an issue in this line: https://github.com/jarcoal/httpmock/blob/v1/match.go#L246 . Could you check, please?The text was updated successfully, but these errors were encountered: