diff --git a/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt b/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt index 4418e5d..d2c9044 100644 --- a/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt +++ b/shared/src/commonTest/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryTest.kt @@ -46,14 +46,10 @@ class RepositoryTest() { @Test fun `Instantiate repository`() { - val success = try { - Repository(api, appSettingsService, connectivityStatus, db) - true - } catch (e: Exception) { - false - } + Repository(api, appSettingsService, connectivityStatus, db) - assertEquals(true, success) + coVerify(exactly = 1) { api.version() } + coVerify(exactly = 1) { api.stats() } } @Test @@ -61,28 +57,23 @@ class RepositoryTest() { every { appSettingsService.getApiVersion() } returns -1 every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false) - val success = try { - Repository(api, appSettingsService, connectivityStatus, db) - true - } catch (e: Exception) { - false - } + Repository(api, appSettingsService, connectivityStatus, db) - assertEquals(true, success) + coVerify(exactly = 0) { api.version() } + coVerify(exactly = 0) { api.stats() } } @Test fun `Instantiate repository with negative stats`() { coEvery { api.stats() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.Stats(-100, -50, -20)) - val success = try { - Repository(api, appSettingsService, connectivityStatus, db) - true - } catch (e: Exception) { - false - } + val repository = Repository(api, appSettingsService, connectivityStatus, db) - assertEquals(true, success) + assertEquals(0, repository.badgeAll) + assertEquals(0, repository.badgeStarred) + assertEquals(0, repository.badgeUnread) + coVerify(exactly = 1) { api.version() } + coVerify(exactly = 1) { api.stats() } } @Test