Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Fix Xtream timeout cancellation test

David Nashash6dfbc896c0f5
diff --git a/data/src/test/java/com/streamvault/data/remote/xtream/OkHttpXtreamApiServiceTest.kt b/data/src/test/java/com/streamvault/data/remote/xtream/OkHttpXtreamApiServiceTest.kt
index 0728112f..e06d3738 100644
--- a/data/src/test/java/com/streamvault/data/remote/xtream/OkHttpXtreamApiServiceTest.kt
+++ b/data/src/test/java/com/streamvault/data/remote/xtream/OkHttpXtreamApiServiceTest.kt
@@ -8,7 +8,9 @@ import java.io.IOException
import java.net.SocketTimeoutException
import java.util.concurrent.atomic.AtomicInteger
import kotlinx.coroutines.CompletableDeferred
+import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withTimeout
+import kotlinx.coroutines.withContext
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.Json
import okhttp3.Interceptor
@@ -160,8 +162,10 @@ class OkHttpXtreamApiServiceTest {
}.exceptionOrNull()
assertThat(failure).isNotNull()
- withTimeout(500) {
- cancellationObserved.await()
+ withContext(Dispatchers.Default.limitedParallelism(1)) {
+ withTimeout(500) {
+ cancellationObserved.await()
+ }
}
}