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

feat(mocks): added support for reusing mocks any times #154

Conversation

nomadesoft
Copy link
Contributor

@nomadesoft nomadesoft commented Aug 29, 2024

Summary

The PR adds support for reusing mocks any number of times by introducing a new AnyTimes method. This method allows a mock to be invoked multiple times without failing the test if it is not used the expected number of times.

Motivation

This feature is very useful in scenarios where the exact number of invocations is not known or not important.

Changes

  1. apitest.go:

    • Modified the assertMocks method to check for anyTimesSet before failing the test if the mock was not invoked the expected number of times.
    • Updated the Mocks method to handle mocks with anyTimesSet.
  2. apitest_test.go:

    • Added a new test TestApiTest_MatchesAnyTimes to verify the functionality of the AnyTimes method.
  3. mocks.go:

    • Added a new boolean field anyTimesSet to the Mock struct.
    • Modified the matches function to skip used mocks if anyTimesSet is true.
    • Added a new method AnyTimes to the MockResponse struct to set the anyTimesSet field.
  4. README.md:

    • Updated the documentation to include usage instructions for the new AnyTimes method.

@nomadesoft nomadesoft marked this pull request as ready for review August 29, 2024 19:05
@steinfletcher steinfletcher merged commit 452fa6e into steinfletcher:master Aug 30, 2024
2 checks passed
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.

2 participants