Colota - Android GPS Location tracker
test: cancel trackingHeartbeatJob in tearDown to avoid UncompletedCoroutinesError
Max Dietrich240c7895dcb2
diff --git a/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.kt b/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.ktindex 2b956ef0..33292a61 100644--- a/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.kt+++ b/apps/mobile/android/app/src/test/java/com/Colota/service/LocationForegroundServiceTest.kt@@ -107,6 +107,14 @@ class LocationForegroundServiceTest {@Afterfun tearDown() {+ // Cancel long-running coroutines started by setupLocationUpdates so runTest doesn't+ // fail with UncompletedCoroutinesError. The tracking heartbeat logger is an infinite+ // loop scoped to serviceScope; explicitly cancel it before tearing down testScope.+ try {+ getField<Job?>("trackingHeartbeatJob")?.cancel()+ } catch (_: Exception) {+ // field may not exist if the test injected a different state - ignore+ }testScope.cancel()Dispatchers.resetMain()unmockkObject(LocationServiceModule)