Skip to content

Support chained expectations in MockClient#566

Merged
ryber merged 1 commit into
Kong:mainfrom
codingkiddo:fix-mockclient-chained-expectations
May 5, 2026
Merged

Support chained expectations in MockClient#566
ryber merged 1 commit into
Kong:mainfrom
codingkiddo:fix-mockclient-chained-expectations

Conversation

@codingkiddo
Copy link
Copy Markdown

Summary

Adds support for chained MockClient expectations when multiple expectations are registered for the same request.

Motivation

Previously, duplicate expectations for the same method/path could result in the later expectation overriding the earlier one. This made it difficult to model ordered responses for repeated calls to the same endpoint.

Fixes #531.

Changes

  • Updated mock request matching to keep equal-score expectations in registration order.
  • Updated the duplicate expectation test to verify ordered response consumption.
  • Preserved existing verification behavior for consumed expectations.

Testing

mvn -pl unirest-modules-mocks test

@ryber ryber merged commit 9a7c10d into Kong:main May 5, 2026
1 check passed
@ryber
Copy link
Copy Markdown
Collaborator

ryber commented May 5, 2026

Thanks, I have a few housekeeping things I'm going to add and then I will cut a release. This will need to be a minor bump since it does change behavior and may cause failing tests for some users

@codingkiddo
Copy link
Copy Markdown
Author

Thanks! That makes sense.

I agree this is a behavior change, so a minor version bump sounds appropriate. Glad to see it will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chaining Expectations In MockClient

2 participants