You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SQLDeligth is commonly used in Kotlin Multiplatform projects for state management. The generated queries can trivially be stubbed with Mockative given a few additional tools, which could be provided by a support library for mocking SQLDelight queries using Mockative, or as a non-mockative extension library. In particular, adding code like the following two classes will enable stubbing of SQLDelight generated queries using Mockative:
classIteratorCursor<RowType:Any>(privatevalresults:Iterator<RowType>) : SqlCursor {
// Could also use AtomicRef from `kotlinx.atomicfu`privatevar_current:RowType? by AtomicReference(null)
// Could also use `by atomic()` from `kotlinx.atomicfu`privatevar isClosed:Boolean by atomic(false)
val current:RowType?
get() =_currentoverridefunclose() {
isClosed =true
}
overridefungetBytes(index:Int) =throwIllegalStateException()
overridefungetDouble(index:Int) =throwIllegalStateException()
overridefungetLong(index:Int) =throwIllegalStateException()
overridefungetString(index:Int) =throwIllegalStateException()
overridefunnext(): Boolean {
if (isClosed) {
throwIllegalStateException("The cursor is closed")
}
if (results.hasNext()) {
_current= results.next()
returntrue
}
returnfalse
}
}
SQLDeligth is commonly used in Kotlin Multiplatform projects for state management. The generated queries can trivially be stubbed with Mockative given a few additional tools, which could be provided by a support library for mocking SQLDelight queries using Mockative, or as a non-mockative extension library. In particular, adding code like the following two classes will enable stubbing of SQLDelight generated queries using Mockative:
Having these pieces you could write test stub code like the following:
The text was updated successfully, but these errors were encountered: