go-sqlmock
go-sqlmock copied to clipboard
set expectations to run multiple times
trafficstars
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
@l3pp4rd few weeks back i required this at my work place, do you think it is good enough to include ?
well, this is something that I do not like. the reasons are:
- it will force sqlmock to lose the strict ordered matching.
- it adds more than needed to the library
- 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.
- 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.