Add test on RustRoomDirectoryList

This commit is contained in:
Benoit Marty 2024-09-19 15:40:25 +02:00
parent a7d4babf48
commit d1be4349f0
4 changed files with 143 additions and 10 deletions

View file

@ -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()
}