Filtering by Consumers when loading from PactBroker is broken
See original GitHub issueWhen loading pacts from the PactBroker, one can filter them by consumer(s) using the system-property:
-Dpactbroker.consumers=my-consumer-name
When doing this however, it always results in a “NoPactsFoundException”. Without this parameter, it does find the pact correctly for this consumer.
The reason seems to be in the PactBrokerLoader class, in line 195:
if (pactBrokerConsumers.isNotEmpty()) {
val consumerInclusions = pactBrokerConsumers.flatMap { parseListExpression(it, resolver) }
consumers = consumers.filter { consumerInclusions.isEmpty() || consumerInclusions.contains(it.name) }
}
According to my tests, “consumers” is a List of “PactBrokerResult” instances. The PactBrokerResult has a “name” field, but it contains the following text:
Pact between my-consumer-name (d49036c9b747af48c33fc66de0ddf7af57756c49) and my-provider-name
This text does NOT match the “consumerInclusions”, they merely contain “my-consumer-name”.
One solution could be to simply check that “my-consumer-name” is contained in the result’s name field in any position, but this sounds hacky, it would probably be better to load the specific pact from the broker and check the real consumer name, but that’s one call more for each consumer.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:13 (1 by maintainers)
Top GitHub Comments
@artemptushkin 4.1.8 is out. I am going to close this based on your testing.
Amazing @artemptushkin ! Thank you so much for testing. I’ll try and release a new version when I get a chance, unless @rholshausen gets there before me.