pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Improve Pacts Version Selector to be able to manage contract changes #1292

Open Seraphiou opened 3 years ago

Seraphiou commented 3 years ago

Hello, Today I use pact to verify all my contracts when there is a pull request, I'm using the same branch name for the consumer/provider as suggested in the documentation.

The problem is that if another consumer has a pact on master => this pact will not be verified by pr build. So on my PR system I added tags = ["branchNameWithNewPact","master"]. But this is not loading all the pacts (and even if it was there would be an issue : the old deprecated pact would be verified as well as the new one on the evolving consumer ).

What I want is to verify "branchNameWithNewPact" tagged pacts for the consumer I'm making evolve, and load the other consumers pacts from "master" tag.

How is this possible ? Am I doing something wrong ? Today I'm thinking about Overriding the PactBrokerLoader class, but that seems to be huge to maintain.

Thanks for your great tool and for your help !

Seraphiou commented 3 years ago

Example : Situation on master Consumer A : Pact A1 version 1 Consumer B : Pact B1 version 1 Provider C : Pact A1 B1 version 1 Broker has A1,B1 (both tagged master)

Lets say I am doing an evolution of pact A1

Situation on the PullRequest branch named "A1ToA2Branch"

Consumer A : Pact A2 version 2 Provider C : Pact A2 version 2

Broker has A2(tagged A1ToA2Branch) , A1 and B1 (both tagged master)

If I check the contract related to A1ToA2Branch, I will only verify A2. But I still want to verify B1 ? How could I verify both A2 and B1 on the PR ?

uglyog commented 3 years ago

What version of Pact-JVM are you using?

Seraphiou commented 3 years ago

What version of Pact-JVM are you using?

4.1.15

uglyog commented 3 years ago

Can you confirm that the pacts on the feature branch and master are different? If they have the same content, the Pact Broker will consider them to be the same Pact. Tags are just pointers to versions of Pact files, so if they have the same content, then both tags are pointing to the same file.

Seraphiou commented 3 years ago

They are different versions. The pact is evolving, so the endpoint with the pact is also evolving and may have several consumers, so I want to verify all consumers from master unless for the consumer for which I created a PR. By doing this I could be able to see all the consumers impacted by this change.