Skip to content

feat: add no pacts is error verification option - #840

Open
hidingmyname wants to merge 1 commit into
pact-foundation:masterfrom
hidingmyname:feat/no-pacts-is-error-839
Open

hidingmyname wants to merge 1 commit into
pact-foundation:masterfrom
hidingmyname:feat/no-pacts-is-error-839

Conversation

@hidingmyname

Copy link
Copy Markdown

Closes #839

Adds a noPactsIsError option to VerificationOptions, as discussed in #839, so a provider verification can succeed when the Pact Broker has no pacts for the provider. This is the same FFI setting pact-ruby exposes as fail_if_no_pacts_found.

$config->getVerificationOptions()->setNoPactsIsError(false);

Changes

  • VerificationOptions / VerificationOptionsInterface: isNoPactsIsError() and setNoPactsIsError(), default true.
  • FFI\Client / FFI\ClientInterface: wrap pactffi_verifier_set_no_pacts_is_error.
  • Verifier: apply the option together with the other verification options.

Compatibility: the default matches the default in libpact_ffi (no_pacts_is_error: true), so current behaviour does not change. VerificationOptionsInterface and ClientInterface gain new methods, which would affect anyone implementing those interfaces themselves.

Scope: in libpact_ffi this setting only applies when the broker reports no pacts. Other load failures, such as a broker that cannot be reached or invalid pact files, still fail the verification.

Tests

composer test: 1008 tests pass with this change. Without it, the 18 cases that call the new method fail (ClientTest and VerifierTest). ClientTest calls the new function through the real libpact_ffi 0.5.10. composer lint and composer static-code-analysis pass.

I also ran Verifier::verify() with the real library against a small local stub broker, once returning a 404 and once returning an empty pacts list. The results were the same for both:

Configuration verify()
default false
setNoPactsIsError(true) false
setNoPactsIsError(false) true

Without this change the default also returns false. Tested with PHP 8.4.27, PHPUnit 11.5.57. I did not run this against a real Pact Broker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the FFI "no pacts is error" verifier option

1 participant