Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Calling EXPECT().MinTimes(1).MaxTimes(1) / MaxTimes(1).MinTimes(1) is confusing #331

Closed
lukedirtwalker opened this issue Oct 11, 2019 · 4 comments

Comments

@lukedirtwalker
Copy link

The documentation says:

If AnyTimes or MaxTimes have not been called, MinTimes sets the maximum number of calls to infinity.

But if MaxTimes is called with argument 1 the MinTimes code considers this as MaxTimes has not been called yet.
See

mock/gomock/call.go

Lines 89 to 91 in dd8d2a2

if c.maxCalls == 1 {
c.maxCalls = 1e8
}

and

mock/gomock/call.go

Lines 99 to 101 in dd8d2a2

if c.minCalls == 1 {
c.minCalls = 0
}

This is confusing and should either be fixed in the documentation or by adding a flag to check whether Min/Max-Times was called.

@codyoss
Copy link
Member

codyoss commented Oct 12, 2019

Hey @lukedirtwalker sorry you found this confusing. This sounds like a docs update to me, are you interested in raising a PR?

@rkpatel7
Copy link
Contributor

I can go ahead and update the documentation to reflect what the code is actually checking.

@codyoss
Copy link
Member

codyoss commented Oct 18, 2019

That would be awesome @rkpatel7, the issue is yours!

@rkpatel7
Copy link
Contributor

Thanks @codyoss! Hopefully my suggested update improves the clarity of the documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants