go-sqlmock
go-sqlmock copied to clipboard
When expectations are not met show received argument values
trafficstars
I am trying to test the execution of an UPDATE query. The output of the failed execution is:
there were unfulfilled expectations: there is a remaining expectation which was not matched: ExpectedExec => expecting Exec or ExecContext which:
- matches sql: 'UPDATE `issue`'
- is with arguments:
0 - 3
1 - Issue_1_updated
2 - Issue_1_updated
3 -
4 -
5 - 1
6 - true
7 - true
8 - <nil>
9 - {}
10 - <nil>
11 - 1
- should return Result having:
LastInsertId: 1
RowsAffected: 1
FAIL
I was able to understand what didn't match by playing with sqlmock.AnyArg(). Rather than having to do that it would be helpful to have an output that tells me what values where received as arguments as well, so I can quickly do a visual comparison of what was expected and what were the actual values used.
@l3pp4rd Wonder what the chances of making this happen are, or if there's a workaround.
Hi, I agree this could be helpful, but currently I’m too busy with a child. If you could contribute it, that would be useful