Corey
03/27/2026, 9:20 PMtransaction {} blocks from Exposed, but I keep running into an exception saying that no default database is configured.
I don’t want to spin up H2 or any in-memory database just for these tests, since that feels like overkill for simple unit testing. In older versions of Exposed, I remember being able to extend TransactionManager to work around this, but it’s no longer an open class.
I’m a bit surprised there isn’t a built-in way to mock or bypass transactions for unit tests. What’s the recommended approach for handling this?Corey
03/27/2026, 9:34 PMinterface Transactional {
fun <T> execute(block: () -> T): T
}
class ExposedTransactional : Transactional {
override fun <T> execute(block: () -> T): T = transaction { block() }
}
class TestTransactional : Transactional {
override fun <T> execute(block: () -> T): T = block()
}
then services that have to wrap multiple repository calls in a transaction will use the abstraction.Chantal Loncle
03/31/2026, 1:40 PM