Alan Boshier
08/01/2024, 10:54 AMpactbroker.consumerName
and pactbroker.pactUrl
, I assumed I would need to set the following verify options when calling new Verifier(opts).verifyProvider()
• pactUrls
set to an array containing the a single string with value set from pactbroker.pactUrl
• consumerVersionSelectors
set to an array containing a single `consumer`selector with value set from pactbroker.consumerName
for example:
{
"pactBrokerUrl": "https://...",
"provider": "foo",
"providerBaseUrl": "<http://localhost:55020>",
"logLevel": "info",
"providerVersionTags": [],
"consumerVersionSelectors": [
{
"consumer": "bar" <<-- value set from pactbroker.consumerName
}
],
"pactUrls": [
"<full url to pact as passed via pactbroker.pactUrl>"
]
}
When I run this, the test retrieves the specific pact via that URL, and runs the given tests successfully. But it then fails with:
2024-08-01T10:48:00.164788Z ERROR ThreadId(12) pact_verifier: Failed to load pact - No pacts found for provider 'foo' matching the given consumer version selectors in pact broker 'https://...': failed validation - ["consumerVersionSelectors: must specify a value for environment or tag or branch, or specify mainBranch=true, matchingBranch=true, latest=true, deployed=true, released=true or deployedOrReleased=true (at index 0)"]
That seems odd, because I don't know what the environment/tag/branch is (and surely that's all wrapped up in the pact on the other end of the URL?).
If I omit the consumer version selectors altogether, then it seems to verify all pacts from all consumers.
What's the correct way to specify that I just want to verify the pact with a given URL?Yousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
Alan Boshier
08/01/2024, 11:17 AM{
"pactBrokerUrl": "...",
"provider": "foo",
"providerBaseUrl": "...",
"logLevel": "info",
"providerVersionTags": [],
"pactUrls": [ <pactUrl> ]
}
but that resulted in not only verifying the pact with the specific URL, but also all pacts from all consumers.Yousaf Nabi (pactflow.io)
"provider"
option?
I have a feeling that it is being passed to a consumer version selector call to the broker, and fetching latest for each associated consumer for the providerAlan Boshier
08/01/2024, 11:19 AMAlan Boshier
08/01/2024, 11:28 AMpactBrokerUrl
too once I had removed provider
from the opts.
Thanks for your help on this; if I can make a couple of suggestions on this:
• Part of my problem was switching from running verification in pact-jvm and pact-js; in the former it is more liberal in what it accepts (i.e. if I passed in a pact url and a pact broker url and a consumer selector, it politely ignored the superfluous stuff. I get that I shouldn't be doing that now, though).
• The online docs might benefit from being more specific about how to handle the pactUrl case (i.e. that you *must not specify pactBrokerUrl, consumerVersionSelectors provider when you do this)Yousaf Nabi (pactflow.io)
• The online docs might benefit from being more specific about how to handle the pactUrl case (i.e. that you *must not specify pactBrokerUrl, consumerVersionSelectors provider when you do this)yep deffo think we can be more explicit. Have you seen this page? https://docs.pact.io/provider/recommended_configuration#verification-triggered-by-a-contract-requiring-verification-published
When the pact URL is known, theHaving us detect that in code and informing the user would be a better DX experience for sure,pactBrokerUrl
,providerName
,consumerVersionSelectors/consumerVersionTags
,enablePending
fields should not be set. You can see an example of switching between the two verification modes (all vs changed) in this Node exampleincludeWipPactsSince
Alan Boshier
08/01/2024, 1:25 PM