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

set expectations to run multiple times #257

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yashschandra
Copy link

@yashschandra yashschandra commented Mar 11, 2021

Added new "times" method which can set expectation to run same query multiple number of times. eg.

mock.ExpectExec("DELETE FROM users"). WillReturnResult(NewResult(1, 1)).Times(3)
will expect same query 3 times

@yashschandra
Copy link
Author

@l3pp4rd few weeks back i required this at my work place, do you think it is good enough to include ?

@l3pp4rd
Copy link
Member

l3pp4rd commented Apr 2, 2021

well, this is something that I do not like. the reasons are:

  1. it will force sqlmock to lose the strict ordered matching.
  2. it adds more than needed to the library
  3. it is simple enough to mock a call few times in test. for example creating a function variable in test to just append the same expectation to mock, but do not lose the strict ordered matching.
  4. I do not want to add interfaces to the library, which only makes some things to be done easier for users, because this is the same as building the framework, in the end it becomes unmanageable.

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.

None yet

2 participants