Test delete source
All checks were successful
continuous-integration/drone/pr Build is passing

This commit is contained in:
davidoskky 2022-09-26 22:26:01 +02:00
parent 63c550ead3
commit 71c0a4d340

View File

@ -551,6 +551,49 @@ class RepositoryTest() {
coVerify(exactly = 0) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } coVerify(exactly = 0) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) }
assertSame(false, response) assertSame(false, response)
} }
@Test
fun `delete source`() {
coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(true)
val repository = Repository(api, appSettingsService, connectivityStatus, db)
var response = false
runBlocking {
response = repository.deleteSource(5)
}
coVerify(exactly = 1) { api.deleteSource(5) }
assertSame(true, response)
}
@Test
fun `delete source but response fails`() {
coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false)
val repository = Repository(api, appSettingsService, connectivityStatus, db)
var response = false
runBlocking {
response = repository.deleteSource(5)
}
coVerify(exactly = 1) { api.deleteSource(5) }
assertSame(false, response)
}
@Test
fun `delete source without connection`() {
coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false)
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
val repository = Repository(api, appSettingsService, connectivityStatus, db)
var response = false
runBlocking {
response = repository.deleteSource(5)
}
coVerify(exactly = 0) { api.deleteSource(5) }
assertSame(false, response)
}
} }
fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List<ITEM> { fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List<ITEM> {