Test create source
This commit is contained in:
parent
366b2e10f1
commit
63c550ead3
@ -181,6 +181,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add tests
|
||||||
suspend fun markAsRead(item: SelfossModel.Item): Boolean {
|
suspend fun markAsRead(item: SelfossModel.Item): Boolean {
|
||||||
val success = markAsReadById(item.id)
|
val success = markAsReadById(item.id)
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add tests
|
||||||
suspend fun unmarkAsRead(item: SelfossModel.Item): Boolean {
|
suspend fun unmarkAsRead(item: SelfossModel.Item): Boolean {
|
||||||
val success = unmarkAsReadById(item.id)
|
val success = unmarkAsReadById(item.id)
|
||||||
|
|
||||||
@ -218,6 +219,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add tests
|
||||||
suspend fun starr(item: SelfossModel.Item): Boolean {
|
suspend fun starr(item: SelfossModel.Item): Boolean {
|
||||||
val success = starrById(item.id)
|
val success = starrById(item.id)
|
||||||
|
|
||||||
@ -236,6 +238,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add tests
|
||||||
suspend fun unstarr(item: SelfossModel.Item): Boolean {
|
suspend fun unstarr(item: SelfossModel.Item): Boolean {
|
||||||
val success = unstarrById(item.id)
|
val success = unstarrById(item.id)
|
||||||
|
|
||||||
@ -254,6 +257,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Add tests
|
||||||
suspend fun markAllAsRead(items: ArrayList<SelfossModel.Item>): Boolean {
|
suspend fun markAllAsRead(items: ArrayList<SelfossModel.Item>): Boolean {
|
||||||
var success = false
|
var success = false
|
||||||
|
|
||||||
|
@ -505,6 +505,52 @@ class RepositoryTest() {
|
|||||||
coVerify(exactly = 0) { api.sources() }
|
coVerify(exactly = 0) { api.sources() }
|
||||||
verify(exactly = 0) { db.sourcesQueries.sources().executeAsList() }
|
verify(exactly = 0) { db.sourcesQueries.sources().executeAsList() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `create source`() {
|
||||||
|
coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns
|
||||||
|
SelfossModel.SuccessResponse(true)
|
||||||
|
|
||||||
|
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||||
|
var response = false
|
||||||
|
runBlocking {
|
||||||
|
response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
coVerify(exactly = 1) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) }
|
||||||
|
assertSame(true, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `create source but response fails`() {
|
||||||
|
coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns
|
||||||
|
SelfossModel.SuccessResponse(false)
|
||||||
|
|
||||||
|
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||||
|
var response = false
|
||||||
|
runBlocking {
|
||||||
|
response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
coVerify(exactly = 1) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) }
|
||||||
|
assertSame(false, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `create source without connection`() {
|
||||||
|
coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns
|
||||||
|
SelfossModel.SuccessResponse(true)
|
||||||
|
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||||
|
|
||||||
|
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||||
|
var response = false
|
||||||
|
runBlocking {
|
||||||
|
response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
coVerify(exactly = 0) { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) }
|
||||||
|
assertSame(false, response)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List<ITEM> {
|
fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List<ITEM> {
|
||||||
|
Loading…
Reference in New Issue
Block a user