pact-foundation / pact-reference

Reference implementations for the pact specifications
https://pact.io
MIT License
91 stars 46 forks source link

Support running a single interaction when verifying a pact #451

Closed canny[bot] closed 3 weeks ago

canny[bot] commented 3 months ago

The pact ruby implementation allows the user to replay a single interaction from a pact at a time. This makes it much easier to fix failing interactions as pacts can get quite large, and there can be a lot of noise when reporting the failure of every interaction at once. The pact ruby implementation is being replaced by the pact rust shared core, which does not yet support this feature. I think we should work out how we could add support for it. The interactionId field that is added by the Pact Broker is suitable for this purpose.

It is possible that this might be best implemented as a Pact Broker feature by passing through another parameter in the 'pacts for verification' call.

https://pact.canny.io/admin/board/feature-requests/p/support-running-a-single-interaction-when-verifying-a-pact

canny[bot] commented 3 months ago

This issue has been linked to a Canny post: Support running a single interaction when verifying a pact :tada:

YOU54F commented 3 weeks ago

The equivalent behaviour has been implemented in the rust shared core, exposed via environment variables, as per the pact-ruby implementation - user facing docs here

Interactions can be filtered via the CLI

https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli#command-line-interface

Filtering interactions:
      --filter-description <filter-description>
          Only validate interactions whose descriptions match this filter (regex format) [env: PACT_DESCRIPTION=]
      --filter-state <filter-state>
          Only validate interactions whose provider states match this filter (regex format) [env: PACT_PROVIDER_STATE=]
      --filter-no-state
          Only validate interactions that have no defined provider state [env: PACT_PROVIDER_NO_STATE=]
  -c, --filter-consumer <filter-consumer>
          Consumer name to filter the pacts to be verified (can be repeated)

They can be controlled externally when using libpact_ffi consumed in other languages by env vars