Add test on RustRoomDirectoryList
This commit is contained in:
parent
a7d4babf48
commit
d1be4349f0
4 changed files with 143 additions and 10 deletions
|
|
@ -10,6 +10,7 @@ package io.element.android.tests.testutils
|
|||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.test.TestScope
|
||||
import kotlinx.coroutines.test.runTest
|
||||
|
||||
/**
|
||||
|
|
@ -20,3 +21,12 @@ fun runCancellableScopeTest(block: suspend (CoroutineScope) -> Unit) = runTest {
|
|||
block(scope)
|
||||
scope.cancel()
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a test with a [CoroutineScope] that will be cancelled automatically and avoiding failing the test.
|
||||
*/
|
||||
fun runCancellableScopeTestWithTestScope(block: suspend (testScope: TestScope, cancellableScope: CoroutineScope) -> Unit) = runTest {
|
||||
val scope = CoroutineScope(coroutineContext + SupervisorJob())
|
||||
block(this, scope)
|
||||
scope.cancel()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue