Test update remote

This commit is contained in:
davidoskky 2022-09-26 22:42:24 +02:00
parent 71c0a4d340
commit bf6f1a917e

View File

@ -594,6 +594,49 @@ class RepositoryTest() {
coVerify(exactly = 0) { api.deleteSource(5) }
assertSame(false, response)
}
@Test
fun `update remote`() {
coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "finished")
val repository = Repository(api, appSettingsService, connectivityStatus, db)
var response = false
runBlocking {
response = repository.updateRemote()
}
coVerify(exactly = 1) { api.update() }
assertSame(true, response)
}
@Test
fun `update remote but response fails`() {
coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "undocumented...")
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 without connection`() {
coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "undocumented...")
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
val repository = Repository(api, appSettingsService, connectivityStatus, db)
var response = false
runBlocking {
response = repository.updateRemote()
}
coVerify(exactly = 0) { api.update() }
assertSame(false, response)
}
}
fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List<ITEM> {