Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive failure when comparing metadata with matchingRules #1749

Closed
robpre opened this issue Dec 14, 2023 · 0 comments
Closed

False positive failure when comparing metadata with matchingRules #1749

robpre opened this issue Dec 14, 2023 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@robpre
Copy link

robpre commented Dec 14, 2023

Hi, while comparing metadata using the consumer Matchers.string we found that we were getting peculiar error messages.
Our example produces this error:

 1.1) metadata: Expected 'mock value' (String) to be the same type as 'someString' (String)

The consumer pact generator looks like:

...
  @Pact(consumer = "foo-service")
  public V4Pact exampleForGithub(MessagePactBuilder builder) {
    return builder
        .given("Some State")
        .expectsToReceive("A message with metadata")
        .withMetadata(Map.of("someKey", Matchers.string("someString")))
        .withContent(new PactDslJsonBody()
            .stringType("someField", "someValue")
        )
        .toPact();
  }
...

Produces a pact json like so:

...
      "matchingRules": {
        "body": {...},
        "metadata": {
          "someKey": {
            "combine": "AND",
            "matchers": [{ "match": "type" }]
          }
        }
      },
      "metadata": { "someKey": "someString" },
      "providerStates": [{ "name": "Some State" }],
      "type": "Asynchronous/Messages"
...

I made a branch which has this example in a failing test: master...robpre:pact-jvm:example-error-matching

I ran it down to the mismatch being that MatcherExecutor's function, matchType, compares actual as "mock value" and expected is a JsonValue.StringValue("someString").

Please can you let me know if I've done something wrong here, thanks!

@rholshausen rholshausen added the bug Indicates an unexpected problem or unintended behavior label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants