Test delete source
This commit is contained in:
parent
63c550ead3
commit
71c0a4d340
@ -551,6 +551,49 @@ class RepositoryTest() {
|
||||
coVerify(exactly = 0) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) }
|
||||
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> {
|
||||
|
Loading…
Reference in New Issue
Block a user