chore(deps): update dependency app.cash.turbine:turbine to v0.8.0 (#1890)

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
renovate[bot] 2022-05-02 23:21:58 +05:30 committed by GitHub
parent e025b120ed
commit 07a83a33b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 42 deletions

View file

@ -1,37 +0,0 @@
/*
* Copyright © 2014-2022 The Android Password Store Authors. All Rights Reserved.
* SPDX-License-Identifier: GPL-3.0-only
*/
package dev.msfjarvis.aps.test
import app.cash.turbine.FlowTurbine
import app.cash.turbine.test
import kotlin.coroutines.coroutineContext
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlin.time.ExperimentalTime
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.test.TestCoroutineScheduler
import kotlinx.coroutines.test.UnconfinedTestDispatcher
/**
* Wrapper for [test] that implements compatibility with kotlinx.coroutines 1.6.0
*
* @see "https://github.com/cashapp/turbine/issues/42#issuecomment-1000317026"
*/
@ExperimentalTime
@ExperimentalCoroutinesApi
public suspend fun <T> Flow<T>.test2(
timeout: Duration = 1.seconds,
validate: suspend FlowTurbine<T>.() -> Unit,
) {
val testScheduler = coroutineContext[TestCoroutineScheduler]
return if (testScheduler == null) {
test(timeout, validate)
} else {
flowOn(UnconfinedTestDispatcher(testScheduler)).test(timeout, validate)
}
}

View file

@ -5,8 +5,8 @@
package dev.msfjarvis.aps.data.passfile package dev.msfjarvis.aps.data.passfile
import app.cash.turbine.test
import dev.msfjarvis.aps.test.CoroutineTestRule import dev.msfjarvis.aps.test.CoroutineTestRule
import dev.msfjarvis.aps.test.test2
import dev.msfjarvis.aps.util.time.TestUserClock import dev.msfjarvis.aps.util.time.TestUserClock
import dev.msfjarvis.aps.util.time.UserClock import dev.msfjarvis.aps.util.time.UserClock
import dev.msfjarvis.aps.util.totp.TotpFinder import dev.msfjarvis.aps.util.totp.TotpFinder
@ -135,7 +135,7 @@ class PasswordEntryTest {
fun testGeneratesOtpFromTotpUri() = runTest { fun testGeneratesOtpFromTotpUri() = runTest {
val entry = makeEntry("secret\nextra\n$TOTP_URI") val entry = makeEntry("secret\nextra\n$TOTP_URI")
assertTrue(entry.hasTotp()) assertTrue(entry.hasTotp())
entry.totp.test2 { entry.totp.test {
val otp = expectMostRecentItem() val otp = expectMostRecentItem()
assertEquals("818800", otp.value) assertEquals("818800", otp.value)
assertEquals(30.seconds, otp.remainingTime) assertEquals(30.seconds, otp.remainingTime)
@ -152,7 +152,7 @@ class PasswordEntryTest {
fun testGeneratedOtpHasCorrectRemainingTime() = runTest { fun testGeneratedOtpHasCorrectRemainingTime() = runTest {
val entry = makeEntry("secret\nextra\n$TOTP_URI", TestUserClock.withAddedSeconds(5)) val entry = makeEntry("secret\nextra\n$TOTP_URI", TestUserClock.withAddedSeconds(5))
assertTrue(entry.hasTotp()) assertTrue(entry.hasTotp())
entry.totp.test2 { entry.totp.test {
val otp = expectMostRecentItem() val otp = expectMostRecentItem()
assertEquals("818800", otp.value) assertEquals("818800", otp.value)
assertEquals(25.seconds, otp.remainingTime) assertEquals(25.seconds, otp.remainingTime)
@ -164,7 +164,7 @@ class PasswordEntryTest {
fun testGeneratesOtpWithOnlyUriInFile() = runTest { fun testGeneratesOtpWithOnlyUriInFile() = runTest {
val entry = makeEntry(TOTP_URI) val entry = makeEntry(TOTP_URI)
assertNull(entry.password) assertNull(entry.password)
entry.totp.test2 { entry.totp.test {
val otp = expectMostRecentItem() val otp = expectMostRecentItem()
assertEquals("818800", otp.value) assertEquals("818800", otp.value)
assertEquals(30.seconds, otp.remainingTime) assertEquals(30.seconds, otp.remainingTime)

View file

@ -98,7 +98,7 @@ testing-junit = "junit:junit:4.13.2"
testing-kotlintest-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" } testing-kotlintest-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
testing-robolectric = "org.robolectric:robolectric:4.8" testing-robolectric = "org.robolectric:robolectric:4.8"
testing-sharedPrefsMock = "com.github.android-password-store:shared-preferences-fake:2.0.0" testing-sharedPrefsMock = "com.github.android-password-store:shared-preferences-fake:2.0.0"
testing-turbine = "app.cash.turbine:turbine:0.7.0" testing-turbine = "app.cash.turbine:turbine:0.8.0"
[bundles] [bundles]
androidxLifecycle = ["androidx-lifecycle-common", "androidx-lifecycle-livedataKtx", "androidx-lifecycle-viewmodelKtx"] androidxLifecycle = ["androidx-lifecycle-common", "androidx-lifecycle-livedataKtx", "androidx-lifecycle-viewmodelKtx"]