Repository Unit Tests #50
@ -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