Closed dcu closed 5 years ago
Hi, will need to have a look, but guess this should be possible with standard statement expectation.
@l3pp4rd any update about this?
hi @dcu maybe you are willing to make a contribution? sadly I'm too busy with other projects
no, sorry I'm super super super busy these days. I'd be good at least to define an API for this use case
sqlmock allows to mock the statements and they can be upgraded to *sql.Tx
just like in every sql driver.
func (tx Tx) Stmt(stmt Stmt) *Stmt does not return any error, it always will swap the connection of the statement to tx connection and it is handled internally by the sql driver. So the only problem you may face in prod code, is that it may take some time to do it, for that reason you have a Context where you can set the deadline, but all of this is not managed by any sql driver implementation and has nothing to do with sqlmock.
though, for some go standard library issue, it was not working on go 1.8. the bug was fixed on 1.9 and later
the problem is that I don't have access to the inner stmt because that's created internally by a function
well, sqlmock cannot do anything more convenient for you, it replicates the sql driver interface and allows to mock it.
my code calls internally to
tx.Stmt()
which returns a new statement but there's no way (or at least I can't find it) to set expectation on it.