Skip to content

Commit

Permalink
fix MainViewModelTest
Browse files Browse the repository at this point in the history
  • Loading branch information
softartdev committed Sep 11, 2024
1 parent 9deb228 commit fd38545
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MainViewModelTest {

Mockito.`when`(mockNoteDAO.listFlow).thenReturn(flow { throw SQLiteException() })
mainViewModel.updateNotes()
assertEquals(NoteListResult.Error(null), awaitItem())
Mockito.verify(mockRouter).navigateClearingBackStack(route = AppNavGraph.SignIn.name)

cancelAndIgnoreRemainingEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ class MainViewModel(
.flowOn(Dispatchers.IO)
.catch { throwable ->
Napier.e("", throwable)
val errorName: String = throwable::class.simpleName.orEmpty()
if (errorName.contains("SQLite")) {
mutableStateFlow.value = NoteListResult.Error(throwable.message)
if (throwable::class.simpleName.orEmpty().contains("SQLite")) {
router.navigateClearingBackStack(AppNavGraph.SignIn.name)
} else {
mutableStateFlow.value = NoteListResult.Error(throwable.message)
}
}.launchIn(this)
}.ensureActive()
Expand Down

0 comments on commit fd38545

Please sign in to comment.