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
RFC: PactNet 5.0 PactVerifier Breaking Changes #457
Milestone
Comments
adamrodger
added a commit
that referenced
this issue
May 5, 2023
adamrodger
added a commit
that referenced
this issue
Jun 26, 2023
adamrodger
added a commit
that referenced
this issue
Jun 27, 2023
adamrodger
added a commit
that referenced
this issue
Jun 27, 2023
adamrodger
added a commit
that referenced
this issue
Jun 27, 2023
adamrodger
added a commit
that referenced
this issue
Jun 27, 2023
adamrodger
added a commit
that referenced
this issue
Jun 28, 2023
JohnWinston329
added a commit
to JohnWinston329/pact-net
that referenced
this issue
Dec 26, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Introduction
Below is a request for comments from the community about a potential breaking change to the Pact verifier in PactNet 5.0
Background
Pact specification v4 allows both synchronous HTTP pacts and asynchronous messaging pacts to be present in the same pact file, which was a key limitation of specification v3.
In PactNet 4.x we only support up to specification v3, and so the
PactVerifier
API enforces either verifying HTTP-style pacts or messaging-style pacts, but not both:This means that any v4 pacts containing both HTTP and messaging interactions will fail to verify, because you can't specify both a HTTP and messaging provider on the verifier. Even though the v4 pacts themselves support shared pacts, PactNet 4.x does not.
Proposal
A breaking change is made to PactNet 5.x such that you can specify both a HTTP and messaging 'transport' (which is what the Pact FFI calls them internally):
The breaking changes are:
PactVerifier
requires the provider name as a mandatory constructor parameter (otherwise it would have to be specified on both the HTTP and message transport, and they'd have to match)ServiceProvider
is renamed toWithHttpEndpoint
and the provider name parameter is removedMessagingProvider
is renamed toWithMessages
, the provider name parameter is removed and the messages are supplied directly instead of via an additional call toWithProviderMessages
IPactVerifierMessagingProvider
is no longer needed and is deletedWithXSource
methods are moved toIPactVerifier
IPactVerifierProvider
is no longer needed and is deletedCaveats/Drawbacks
Both
WithHttpEndpoint
andWithMessages
are optional in case a particular service doesn't have both types of interactions, but at least one must be provided and at most one of each type. I would ideally like these invariants to be enforced at compile time but that isn't really possible without introducing a very awkward type hierarchy. Consider:This means you have really awkward types like:
I don't think the added complexity to the types is worth the added runtime safety in this instance, particular given this is a testing library and we can simply throw
InvalidOperationException
if you try to add the same transport twice, or no transports at all. The feedback loop is fast, the error is easy to communicate/fix, and the code isn't production code.It also creates a combinatorial explosion if in future we support more transport types.
The text was updated successfully, but these errors were encountered: