Fix update remote tests
This commit is contained in:
parent
d311c2cdeb
commit
7211fdb1a3
@ -352,7 +352,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
|
||||
suspend fun updateRemote(): Boolean {
|
||||
return if (isNetworkAvailable()) {
|
||||
api.update().equals("finished")
|
||||
api.update().data.equals("finished")
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -718,12 +718,26 @@ class RepositoryTest() {
|
||||
}
|
||||
|
||||
coVerify(exactly = 1) { api.update() }
|
||||
assertSame(true, response)
|
||||
assertTrue(response)
|
||||
}
|
||||
|
||||
@Test
|
||||
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)
|
||||
var response = false
|
||||
|
Loading…
Reference in New Issue
Block a user