Skip to content

Commit

Permalink
[ANDROAPP-5701] remove dispatcher io from viewmodelscope
Browse files Browse the repository at this point in the history
Signed-off-by: andresmr <[email protected]>
  • Loading branch information
andresmr committed Apr 29, 2024
1 parent a4e0a83 commit 9071baa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class GranularSyncPresenter(
}

fun checkServerAvailability() {
viewModelScope.launch(dispatcher.io()) {
viewModelScope.launch {
try {
repository.checkServerAvailability()
_serverAvailability.value = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.dhis2.commons.Constants
import org.dhis2.commons.sync.ConflictType
import org.dhis2.commons.sync.SyncContext
Expand Down Expand Up @@ -55,8 +57,8 @@ class GranularSyncPresenterTest {
private val trampolineSchedulerProvider = TrampolineSchedulerProvider()
private val testingDispatcher = UnconfinedTestDispatcher()
private val testDispatcher: DispatcherProvider = mock {
on { io() } doReturn Dispatchers.Unconfined
on { ui() } doReturn Dispatchers.Unconfined
on { io() } doReturn testingDispatcher
on { ui() } doReturn testingDispatcher
}
private val workManager = Mockito.mock(WorkManagerController::class.java)
private val smsSyncProvider: SMSSyncProvider = mock()
Expand All @@ -65,13 +67,12 @@ class GranularSyncPresenterTest {

@Before
fun setUp() {
// Dispatchers.setMain(testingDispatcher)
Dispatchers.setMain(testingDispatcher)
}

@After
fun tearDown() {
// Dispatchers.resetMain()
// testDispatcher.cleanupTestCoroutines()
Dispatchers.resetMain()
}

@Test
Expand Down

0 comments on commit 9071baa

Please sign in to comment.