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 347 forks source link

`eachKeyLike` matcher isn't eachKeyLike, it is eachValueLike (also rust core version needs a bump) #952

Closed TimothyJones closed 1 year ago

TimothyJones commented 2 years ago

Software versions

Please provide at least OS and version of pact-js

Please confirm the following:

Expected behaviour

As per https://github.com/pact-foundation/pact-reference/issues/216 , eachLike doesn't match correctly. This object:

{
  "john-doe1": {
    "brown-fox": {
      "jumps": "over",
      "the": "lazy dog"
    }
  },
  "john-doe2": {
    "brown-fox2": {
      "jumps": "over",
      "the": "lazy dog"
    }
  }
}

should be matched by

Matchers.eachKeyLike(
   "some string", 
   Matchers.eachKeyLike(
      "some-string", 
      Matchers.eachKeyLike(
         "some-string",
         Matchers.string())))

Actual behaviour

It is not matched - the match only applies at the first level.

Steps to reproduce

As above

Extra information

To get the fix, we'll need to bump the rust core to at least 0.3.12.

Also, as @uglyog pointed out:

BTW, the eachKeyLike function is incorrectly named. It should be something like eachValueLike.

Probably the right fix for this is:

mefellows commented 2 years ago

Thanks for raising/moving this here Tim.

The pact-core package release just went out with the new fix. This will come in by default based on our dependency rules, but next change we can enforce that too.

As for the functions, I'm confused about how we support the (intended) eachKeyLike function (matching keys, not values), so will need some support on how we implement that from @uglyog. Will use this ticket to track that activity.

mefellows commented 1 year ago

Update on this issue. eachKeyLike should use set pact:matcher:type: "eachKey" as documented here: https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_ffi/IntegrationJson.md

github-actions[bot] commented 1 year ago

👋 Hi! The 'smartbear-supported' label has just been added to this issue, which will create an internal tracking ticket in PactFlow's Jira (PACT-784). We will use this to prioritise and assign a team member to this task. All activity will be public on this ticket. For now, sit tight and we'll update this ticket once we have more information on the next steps.

See our documentaiton for more information.

eburi commented 1 year ago

👋 Hi, There has been no changes related to this issue, #662 and #1077 - is there anything I can do so that this bug will be addressed?

mefellows commented 1 year ago

You could submit a PR to fix it?