pact-foundation / pact-reference

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

Verifier Results with empty notices #404

Closed JP-Ellis closed 3 months ago

JP-Ellis commented 3 months ago

When implementing the compatibility suite, I came across the following scenario (ref)

  Scenario: Verifying an interaction where a provider state callback is not configured
    Given a provider is started that returns the response from interaction 1
    And a Pact file for interaction 1 is to be verified with a provider state "state one" defined
    When the verification is run
    Then the verification will be successful
    And a warning will be displayed that there was no provider state callback configured for provider state "state one"

It requires checking that a warning is displayed, which to my knowledge, is difficult to do through the FFI. When logging is enabled, the FFI does emit the correct warning:

WARN ThreadId(01) verify_interaction{interaction="interaction 1"}: pact_verifier::callback_executors: State Change ignored as there is no state change URL provided for interaction 

However inspecting the logs requires logging to a buffer, and would fail if logging to stderr is configured for example.

Inspecting the verifier results, there is a notices key, though it appears to be empty:

{
  "errors": [],
  "notices": [],
  "output": [
    "\nVerifying a pact between \u001b[1mconsumer\u001b[0m and \u001b[1mprovider\u001b[0m",
    "",
    "  interaction 1 (0s loading, 159ms verification)",
    "     Given state one",
    "    returns a response which",
    "      has status code \u001b[1m200\u001b[0m (\u001b[32mOK\u001b[0m)",
    "      includes headers",
    "        \"\u001b[1mContent-Type\u001b[0m\" with value \"\u001b[1mapplication/json\u001b[0m\" (\u001b[32mOK\u001b[0m)",
    "      has a matching body (\u001b[32mOK\u001b[0m)",
    "",
    ""
  ],
  "pendingErrors": [],
  "result": true
}

and I am left wondering whether this is an error with the FFI or not.

rholshausen commented 3 months ago

notices contains any notices returned from the Pact Broker.

Just make the step a no-op as the underlying Rust code will emit the warning.

JP-Ellis commented 3 months ago

Cool, I'll make this a no-op.