Hi guys. Please enighten me on how should I instru...
# pact-broker
b
Hi guys. Please enighten me on how should I instruct the provider to run the test against a specific version of the contract and not against the newest contract published in the broker. My Pact broker initially had a contract version that was successfully passing the tests. But then, the team that owns the consumer pushed from their branch a new version of the contract, and the provider tests are failing now, because they run against the latest contract in the Matrix list (contracts in the Matrix are sorted by database id I assume). How can I make the provider tests run against the latest "prod" version of the contract and not against versions published by dev branches? (against c.v.1-PROD according to the screenshot instead of c.v.2.-WorkInProgress) Thank you!
j
If you are using java it would be something like:
Copy code
@PactBrokerConsumerVersionSelectors
  public static SelectorBuilder consumerVersionSelectors() {
    return new SelectorBuilder().latestTag("your tag")
  }
Or set the “pactbroker.tags” property
It doesn’t look like you are using tags from that screenshot however, it looks like your tags are in the version field
b
I am not using tags (yet). So then if I will tag a contract version with "PROD", I could instruct the provider to run against the latest "PROD" version instead of the latest from the list?
j
Yes that should work
b
and the method that you gave as an example ( @PactBrokerConsumerVersionSelectors ) should be part of the provider contract test?
j
Yes, I have it in the same class as the provider verification code
b
k, thanks a lot, will give it some tries
j
No worries
b
@Basu Silviu the CI/CD workshop shows you how to deal with this
b
Thank you @Beth (pactflow.io/Pact Broker/pact-ruby), I will check it
b
You need to use the "pending pacts" feature
Do keep the main branch pact in your selectors. But by turning on pending, it won't break your build.
This is exactly what the feature was designed for.
b
thanks a lot