From a76da935cdb43e0f99513ed6f3468bd0835a5137 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 12 May 2023 18:06:47 +0530 Subject: [PATCH] feat: remove unnecessary CoroutineTestRule --- coroutine-utils-testing/build.gradle.kts | 11 ----- coroutine-utils-testing/lint-baseline.xml | 4 -- .../passwordstore/test/CoroutineTestRule.kt | 48 ------------------- format-common/build.gradle.kts | 1 - .../data/passfile/PasswordEntryTest.kt | 6 --- settings.gradle.kts | 2 - 6 files changed, 72 deletions(-) delete mode 100644 coroutine-utils-testing/build.gradle.kts delete mode 100644 coroutine-utils-testing/lint-baseline.xml delete mode 100644 coroutine-utils-testing/src/main/kotlin/app/passwordstore/test/CoroutineTestRule.kt diff --git a/coroutine-utils-testing/build.gradle.kts b/coroutine-utils-testing/build.gradle.kts deleted file mode 100644 index 6b1c3d81..00000000 --- a/coroutine-utils-testing/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ -plugins { id("com.github.android-password-store.kotlin-jvm-library") } - -dependencies { - implementation(projects.coroutineUtils) - implementation(libs.testing.junit) - implementation(libs.kotlin.coroutines.test) -} diff --git a/coroutine-utils-testing/lint-baseline.xml b/coroutine-utils-testing/lint-baseline.xml deleted file mode 100644 index 752ac952..00000000 --- a/coroutine-utils-testing/lint-baseline.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/coroutine-utils-testing/src/main/kotlin/app/passwordstore/test/CoroutineTestRule.kt b/coroutine-utils-testing/src/main/kotlin/app/passwordstore/test/CoroutineTestRule.kt deleted file mode 100644 index e5e01ba9..00000000 --- a/coroutine-utils-testing/src/main/kotlin/app/passwordstore/test/CoroutineTestRule.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. - * SPDX-License-Identifier: GPL-3.0-only - */ - -package app.passwordstore.test - -import app.passwordstore.util.coroutines.DispatcherProvider -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.TestCoroutineScheduler -import kotlinx.coroutines.test.TestDispatcher -import kotlinx.coroutines.test.UnconfinedTestDispatcher -import kotlinx.coroutines.test.resetMain -import kotlinx.coroutines.test.setMain -import org.junit.rules.TestWatcher -import org.junit.runner.Description - -/** - * JUnit [TestWatcher] to correctly handle setting and resetting a given [testDispatcher] for tests. - */ -@ExperimentalCoroutinesApi -public class CoroutineTestRule( - public val testDispatcher: TestDispatcher = UnconfinedTestDispatcher(TestCoroutineScheduler()), -) : TestWatcher() { - - public val testDispatcherProvider: DispatcherProvider = - object : DispatcherProvider { - override fun default(): CoroutineDispatcher = testDispatcher - - override fun io(): CoroutineDispatcher = testDispatcher - - override fun main(): CoroutineDispatcher = testDispatcher - - override fun unconfined(): CoroutineDispatcher = testDispatcher - } - - override fun starting(description: Description) { - super.starting(description) - Dispatchers.setMain(testDispatcher) - } - - override fun finished(description: Description) { - super.finished(description) - Dispatchers.resetMain() - } -} diff --git a/format-common/build.gradle.kts b/format-common/build.gradle.kts index 3377eb86..01009ab8 100644 --- a/format-common/build.gradle.kts +++ b/format-common/build.gradle.kts @@ -12,7 +12,6 @@ dependencies { implementation(libs.dagger.hilt.core) implementation(libs.thirdparty.commons.codec) implementation(libs.thirdparty.uri) - testImplementation(projects.coroutineUtilsTesting) testImplementation(libs.bundles.testDependencies) testImplementation(libs.kotlin.coroutines.test) testImplementation(libs.testing.turbine) diff --git a/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt b/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt index 73e55b34..865a13c1 100644 --- a/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt +++ b/format-common/src/test/kotlin/app/passwordstore/data/passfile/PasswordEntryTest.kt @@ -7,7 +7,6 @@ package app.passwordstore.data.passfile import app.cash.turbine.Event import app.cash.turbine.test -import app.passwordstore.test.CoroutineTestRule import app.passwordstore.util.time.TestUserClock import app.passwordstore.util.time.UserClock import app.passwordstore.util.totp.UriTotpFinder @@ -18,16 +17,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds -import kotlin.time.ExperimentalTime -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.test.runTest -import org.junit.Rule -@OptIn(ExperimentalCoroutinesApi::class, ExperimentalTime::class) class PasswordEntryTest { - @get:Rule val coroutineTestRule: CoroutineTestRule = CoroutineTestRule() private val totpFinder = UriTotpFinder() private fun makeEntry(content: String, clock: UserClock = fakeClock) = diff --git a/settings.gradle.kts b/settings.gradle.kts index 2435a5cc..eee3fc5e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -171,8 +171,6 @@ include("autofill-parser") include("coroutine-utils") -include("coroutine-utils-testing") - include("crypto-common") include("crypto-pgpainless")