[#667] Fix for Update VM flaky test results
* [#667] Fix for Update VM flaky test results - Added small delays to the AppUpdateCheckerMock functions to copy a real-world situation a bit more - This also helps with satisfying expectations in UpdateViewModelTest * Typo fix * Make duration more explicit Co-authored-by: Carter Jernigan <git@carterjernigan.com>
This commit is contained in:
parent
9401330ff4
commit
00513a18da
|
@ -14,9 +14,11 @@ import com.google.android.play.core.appupdate.testing.FakeAppUpdateManager
|
|||
import com.google.android.play.core.install.model.AppUpdateType
|
||||
import kotlinx.coroutines.channels.ProducerScope
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
|
||||
class AppUpdateCheckerMock private constructor() : AppUpdateChecker {
|
||||
|
||||
|
@ -50,6 +52,9 @@ class AppUpdateCheckerMock private constructor() : AppUpdateChecker {
|
|||
|
||||
val appUpdateInfoTask = fakeAppUpdateManager.appUpdateInfo
|
||||
|
||||
// to simulate a real-world situation
|
||||
delay(100.milliseconds)
|
||||
|
||||
appUpdateInfoTask.addOnCompleteListener { infoTask ->
|
||||
emitResult(this, infoTask.result)
|
||||
}
|
||||
|
@ -74,6 +79,8 @@ class AppUpdateCheckerMock private constructor() : AppUpdateChecker {
|
|||
activity: ComponentActivity,
|
||||
appUpdateInfo: AppUpdateInfo
|
||||
): Flow<Int> = flow {
|
||||
// to simulate a real-world situation
|
||||
delay(100.milliseconds)
|
||||
emit(Activity.RESULT_OK)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue