Repository navigation
feat(ffi): add pactffi_sync_message_match_response_contents - #557
Merged
rholshausen merged 2 commits intoOct 8, 2026
Merged
rholshausen merged 2 commits into
rholshausen merged 2 commits into
Conversation
Consumer tests for synchronous messages can generate the request with pactffi_sync_message_generate_contents, but had no way to check the response the handler under test produces against the expected response's matching rules. Hosts fell back to exact equality with the generated example, so a type matcher still required the example value. The new function matches given contents against an expected response of a sync message interaction, with the same matching context the verifier uses in match_sync_message_response (content rules, unexpected keys allowed). It returns a JSON array of mismatches, empty when the contents match, or NULL for an invalid handle, index or input.
4 tasks done
The V2 matching engine reports a missing key as both a type mismatch and a missing entry, where V1 reports one mismatch, so the exact count check failed in the v2-engine job. Check that the contents matched, or that a mismatch was reported for the expected field, which holds for both.
YOU54F
approved these changes
Oct 8, 2026
YOU54F
left a comment
Member
There was a problem hiding this comment.
Tested against pact-foundation/pact-net#562 and works nicely
I'll wait for a review from Josh and Ron and then I'd be happy to get this merged and released if they have no issue
Contributor
|
Nice one! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
pactffi_sync_message_match_response_contents, so a consumer test for a synchronous message can check the response its handler produces against the expected response's matching rules.pactffi_sync_message_generate_contents(#555) gives the consumer the generated request, but there was no way to check the handler's response with the matchers applied. PactNet (pact-foundation/pact-net#562) fell back to exact equality with the generated example, soMatch.Type("shipped")still required"shipped".[]when the contents match.match_sync_message_responsein the verifier:contentrules, V4, unexpected keys allowed.pactffi_string_delete.Tests
cargo test -p pact_ffi --lib sync_message_match_response, 11 cases:integerrejects a decimal,decimalrejects an integerAlso checked from PactNet against a local build of this branch: 180 tests pass on net8.0 and net462.