Fix update remote tests

This commit is contained in:
davidoskky 2022-09-29 18:58:00 +02:00
parent d311c2cdeb
commit 7211fdb1a3
2 changed files with 17 additions and 3 deletions

View File

@ -352,7 +352,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
suspend fun updateRemote(): Boolean { suspend fun updateRemote(): Boolean {
return if (isNetworkAvailable()) { return if (isNetworkAvailable()) {
api.update().equals("finished") api.update().data.equals("finished")
} else { } else {
false false
} }

View File

@ -718,12 +718,26 @@ class RepositoryTest() {
} }
coVerify(exactly = 1) { api.update() } coVerify(exactly = 1) { api.update() }
assertSame(true, response) assertTrue(response)
} }
@Test @Test
fun `update remote but response fails`() { fun `update remote but response fails`() {
coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "undocumented...") coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "unallowed access")
val repository = Repository(api, appSettingsService, connectivityStatus, db)
var response = false
runBlocking {
response = repository.updateRemote()
}
coVerify(exactly = 1) { api.update() }
assertSame(false, response)
}
@Test
fun `update remote with unallowed access`() {
coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "unallowed access")
val repository = Repository(api, appSettingsService, connectivityStatus, db) val repository = Repository(api, appSettingsService, connectivityStatus, db)
var response = false var response = false