refactor: Remove duplicate `MainCoroutineRule` (#129)

This commit is contained in:
Nik Clayton 2023-09-27 17:53:24 +02:00 committed by GitHub
parent ad167bf293
commit 0b8d702960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 21 deletions

View File

@ -22,23 +22,16 @@ import android.os.Looper
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import app.pachli.appstore.EventHub import app.pachli.appstore.EventHub
import app.pachli.components.timeline.FiltersRepository import app.pachli.components.timeline.FiltersRepository
import app.pachli.components.timeline.MainCoroutineRule
import app.pachli.db.AccountEntity import app.pachli.db.AccountEntity
import app.pachli.db.AccountManager import app.pachli.db.AccountManager
import app.pachli.network.FilterModel import app.pachli.network.FilterModel
import app.pachli.settings.PrefKeys import app.pachli.settings.PrefKeys
import app.pachli.usecase.TimelineCases import app.pachli.usecase.TimelineCases
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestDispatcher
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import okhttp3.ResponseBody import okhttp3.ResponseBody
import okhttp3.ResponseBody.Companion.toResponseBody import okhttp3.ResponseBody.Companion.toResponseBody
import org.junit.Before import org.junit.Before
import org.junit.Rule import org.junit.Rule
import org.junit.rules.TestWatcher
import org.junit.runner.Description
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mockito.kotlin.any import org.mockito.kotlin.any
import org.mockito.kotlin.doAnswer import org.mockito.kotlin.doAnswer
@ -49,19 +42,6 @@ import org.robolectric.annotation.Config
import retrofit2.HttpException import retrofit2.HttpException
import retrofit2.Response import retrofit2.Response
@OptIn(ExperimentalCoroutinesApi::class)
class MainCoroutineRule(private val dispatcher: TestDispatcher = UnconfinedTestDispatcher()) : TestWatcher() {
override fun starting(description: Description) {
super.starting(description)
Dispatchers.setMain(dispatcher)
}
override fun finished(description: Description) {
super.finished(description)
Dispatchers.resetMain()
}
}
@Config(sdk = [28]) @Config(sdk = [28])
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)
abstract class NotificationsViewModelTestBase { abstract class NotificationsViewModelTestBase {