Don't hide potential timeline bugs by catching all exceptions (#2372)

* don't hide potential timeline bugs by catching all exceptions

* fix NetworkTimelineRemoteMediatorTest

* improve ifExpected function

* fix code formatting
This commit is contained in:
Konrad Pozniak 2022-03-08 21:39:59 +01:00 committed by GitHub
commit 34b7a3c8ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 22 deletions

View file

@ -27,7 +27,7 @@ import org.junit.runner.RunWith
import org.robolectric.annotation.Config
import retrofit2.HttpException
import retrofit2.Response
import java.lang.RuntimeException
import java.io.IOException
@Config(sdk = [29])
@RunWith(AndroidJUnit4::class)
@ -66,7 +66,7 @@ class NetworkTimelineRemoteMediatorTest {
val timelineViewModel: NetworkTimelineViewModel = mock {
on { statusData } doReturn mutableListOf()
onBlocking { fetchStatusesForKind(anyOrNull(), anyOrNull(), anyOrNull()) } doThrow RuntimeException()
onBlocking { fetchStatusesForKind(anyOrNull(), anyOrNull(), anyOrNull()) } doThrow IOException()
}
val remoteMediator = NetworkTimelineRemoteMediator(accountManager, timelineViewModel)
@ -74,7 +74,7 @@ class NetworkTimelineRemoteMediatorTest {
val result = runBlocking { remoteMediator.load(LoadType.REFRESH, state()) }
assertTrue(result is RemoteMediator.MediatorResult.Error)
assertTrue((result as RemoteMediator.MediatorResult.Error).throwable is RuntimeException)
assertTrue((result as RemoteMediator.MediatorResult.Error).throwable is IOException)
}
@Test