Is it possible to verify code within a lambda is r...
# mockk
t
Is it possible to verify code within a lambda is ran? With the following code:
Copy code
fun getAllActiveWidgetsByPrice(db: DatabaseConnection): List<Widgets> = db.query {
    Widgets.select {
        Widgets.active eq true
    }.orderBy(Widget.price).map { toWidget(it) }
}
Could we verify that
Widgets.select
is called? Could we verify that we pass a lambda with
Widgets.active eq true
to
Widgets.select
? I feel like there is a way to do this, but I have not been able to get it to work.
h
I think you can mockStatic Widgets. And run verify on the function. The lambda you are passing is anonymous. So you may not verify it is called. You can use any() in the matcher.