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

Update to a matcher doesn't update in the contract #23

Closed
surpher opened this issue Jun 5, 2020 · 3 comments
Closed

Update to a matcher doesn't update in the contract #23

surpher opened this issue Jun 5, 2020 · 3 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@surpher
Copy link
Owner

surpher commented Jun 5, 2020

🌎 Environment

  • Xcode: 11.5
  • Platform: iOS
  • Version/Release: master branch
  • Dependency manager: Carthage 0.38

💬 Description

When writing a pact test and describing a value in body using an updated matcher, the change to that matcher is not reflected in the pact file.
If the pact file is deleted before running updated again, then the update is reflected in the pact file.

🦶 Reproduction Steps

  1. Setup a pact test environment
  2. Write a pact test where .willRespondWith(body:) contains a matcher:
.willRespondWith(body: [
  "related": EachLike("https://someurl.com/entity/related", min: 0, max: 5)
]
  1. Run this cmd + U
  2. Inspect test file to contain "matchingRules" object for:
...
"body": {
  "$.related": {
    "combine": "AND",
    "matchers": [
       {
           "match": "type",
           "max": 5,
           "min": 0
        }
    ]
  },
...
  1. Update matcher to be EachLike("https://someurl.com/entity/related", min: 1, max: 10)
  2. Run this cmd + U
  3. Inspect test file and observe the min: and max: for the provided matcher

🤔 Expected Results

When changing the matcher, the changes should be reflected in the subsequent test runs, eg:

...
"body": {
  "$.related": {
    "combine": "AND",
    "matchers": [
       {
           "match": "type",
           "max": 10,
           "min": 1 
        }
    ]
  },
...

😲 Actual Results

The changes to min: and max: are not recorded and remain set to max: 5 and min: 0

⑂ Possible workaround(s)

Before running the tests again with the changes to any of the matchers (tested with changing a SomethingLike() to EqualTo()), remove any existing pact files in order to completely re-generate any and all pact files.

@surpher surpher added the bug Something isn't working label Jun 5, 2020
@surpher
Copy link
Owner Author

surpher commented Jun 5, 2020

The code that is writing the file is the Pact Mock Server which is brought in as an external dependency (Pact Mock Server). Already reached out to pinpoint where the issue occurs.

An option would be to either forcefully clean any existing JSON files in the target folder before verifying any of the interactions;
Or maybe provide an optional flag to clean up the folder before running the tests.

@surpher surpher changed the title Update to a matcher doesn't result in the contract Update to a matcher doesn't update in the contract Jun 9, 2020
@surpher surpher added this to To do in Beta release - consumer via automation Sep 2, 2020
@surpher surpher added this to the Matchers milestone Sep 2, 2020
@surpher surpher removed this from the Matchers milestone Oct 7, 2020
@surpher surpher moved this from To do to In progress in Beta release - consumer Oct 9, 2020
@surpher surpher self-assigned this Oct 9, 2020
@surpher surpher added the question Further information is requested label Oct 15, 2020
@surpher
Copy link
Owner Author

surpher commented Oct 15, 2020

This might not be a bug but expected behaviour. If it is confirmed that it is working as expected, documentation will be updated accordingly and/or an alternative handling of this will be looked into in PactSwift.

@surpher surpher moved this from In progress to To do in Beta release - consumer Oct 15, 2020
@surpher
Copy link
Owner Author

surpher commented Oct 18, 2020

Confirmed it is a bug in pact_mock_server (pact-foundation/pact-reference#77).
Bug should be fixed with your next build when git submodule update --init --recursive pulls the fixes done in pact-reference submodule.

@surpher surpher moved this from To do to In progress in Beta release - consumer Oct 18, 2020
@surpher surpher closed this as completed Oct 26, 2020
Beta release - consumer automation moved this from In progress to Done Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
No open projects
Development

No branches or pull requests

1 participant