Add test on RustRoomDirectoryList
This commit is contained in:
+10
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user