pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.63k stars 346 forks source link

[V3] publishVerificationResult always pushes the contract to the broker even it set as false #893

Closed harris-linktree closed 2 years ago

harris-linktree commented 2 years ago

publishVerificationResult always pushes the contract to the broker even if it is set as false. However, V2, config works as expected.

Software versions

Please confirm the following:

Expected behaviour

When I set publishVerificationResult to false, it should not upload contracts to the broker

Actual behaviour

When I set publishVerificationResult to false, it uploads contracts to the broker

Steps to reproduce

  1. config option publishVerificationResult set to true and run test to confirm pact uploaded
  2. config option publishVerificationResult set to false and run test to confirm pact uploaded or not
TimothyJones commented 2 years ago

@mefellows: Since this was my code, I'll add some context. I believe this issue is in the Rust verifier.

The argument is mapped here:

https://github.com/pact-foundation/pact-js-core/blob/master/src/verifier/argumentMapper/arguments.ts#L90

The flag mapper is here:

https://github.com/pact-foundation/pact-js-core/blob/master/src/verifier/argumentMapper/index.ts#L71

And the definition of the argument in the rust source is here:

https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_verifier_cli/src/args.rs#L160

My understanding at the time of implementing the argument mapper was that the Verifier CLI treats all booleans as false by default. If the Verifier CLI is updated to support --no-publish or --publish=false, then here is where the corresponding change in pact-js would go.

mefellows commented 2 years ago

Thanks for raising Harris and for that context Tim. Should be an easy one to squash in the next week.

I'm traveling at the moment in the US so likely I won't be able to get to this until next week

mefellows commented 2 years ago

This should be fixed in the latest release (v10.0.1) - can you please check?

harris-linktree commented 2 years ago

This should be fixed in the latest release (v10.0.1) - can you please check?

yeap it is fixed thanks Matt :)

mefellows commented 2 years ago

Great, thanks for confirming!