-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
Unit testing service logic when using - *DB.RunInTx func #587
Comments
IDB is a common interface for *bun.DB, bun.Conn, and bun.Tx. I don't think we can extend it with But we probably can add another interface, for example, |
Some other ORMs offer the same interface also for the transaction, and when you are already in a tx they use The |
@isgj yes, that is an option too. If there is any interest, please send a PR. |
feat: add tx methods to IDB (#587)
I have a service with
*bun.DB
instance and a method that handles a transaction usingRunInTx
func.I would like to add a unit test for this method but in order to do that, I need to use an abstraction over
*bun.DB
which seems to be -
bun.IDB
interface.However,
bun.IDB
is missingRunInTx
func and other "transaction-related" methods like - BeginTx, Begin, etc.simple code example:
Currently, to overcome this issue, I have created this wrapper that can be used instead of
*bun.DB
:However, it would be nice if it was part of
bun.DBI
.Would it be possible to add the "transaction-related" methods to
bun.DBI
(same as in go-pg)?Is there a better approach to handle this case?
TIA, Guy
The text was updated successfully, but these errors were encountered: