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
mock_server_matched returns true when mock_server_mistmatches returns errors #107
Comments
tried to repro this locally - if you could share the test pact setup you have (the request/response you're trying to test) I'll see if I can make it fail. I do recall the problem (hence the comment) but it seems to be working. So it might be some more nefarious bug. |
But to be honest, aside from getting a JSON string, all |
Yeah cool, so you think it's probably better to consider the verification failed if the mismatches string is non-empty, and not call |
Ron might have other views, but for my needs, I get the result and related data in a single call. Looking at the code, there doesn't appear to be other benefits in doing that call (i.e. there are no state mutations). |
|
Makes sense, thanks. I can't reliably reproduce the above problem yet. |
I've run the C test example https://github.com/pact-foundation/pact-reference/tree/master/c/consumer-verification and that is getting the correct values from the FFI functions. That test will fail if This test expects
This test expects
|
You can see here it is actually testing that condition: https://github.com/pact-foundation/pact-reference/blob/master/c/consumer-verification/src/main.c#L178 There must be something else wrong |
So I think I know why this happened now, and it's a bit of an open question whether it should return true or not in that situation (I think it should return false fwiw). If you set up no interactions (which was happening for an unrelated reason) and then make a request, you'll get an error back because of the unexpected request. When you call mock_server_mismatches then you'll get back the details of the unexpected request in the string, but mock_server_matched will return true. Those functions are so similarly named that you'd definitely expect false if you get back an error string. |
This is still confusing to me. let mismatches = mock_server.mismatches().iter()
.map(|mismatch| mismatch.to_json() )
.collect::<Vec<serde_json::Value>>(); How can the former return true (collection is empty) while the latter returns the unexpected request by transforming the collection into JSON. |
I'm writing the Rust FFI interop for PactNet and I've found that
mock_server_matched
returns true even if there are mismatches returned frommock_server_mismatches
. Unfortunately I can only really demonstrate this using the C# code for the PactNet work rather than with proper repro steps:I've also tried it the other way around, only calling
mock_server_mismatches
ifmock_server_matched
returns false, just in case I'm somehow resetting the internal state by grabbing/freeing the mismatches string, butmock_server_matched
seems to just always return true so I never end up pulling the mismatches string.The text was updated successfully, but these errors were encountered: