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
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.
apitest_test.go:
Added a new test TestApiTest_MatchesAnyTimes to verify the functionality of the AnyTimes method.
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.
README.md:
Updated the documentation to include usage instructions for the new AnyTimes method.
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
apitest.go
:assertMocks
method to check foranyTimesSet
before failing the test if the mock was not invoked the expected number of times.Mocks
method to handle mocks withanyTimesSet
.apitest_test.go
:TestApiTest_MatchesAnyTimes
to verify the functionality of theAnyTimes
method.mocks.go
:anyTimesSet
to theMock
struct.matches
function to skip used mocks ifanyTimesSet
is true.AnyTimes
to theMockResponse
struct to set theanyTimesSet
field.README.md
:AnyTimes
method.