Compare commits
No commits in common. "667e9c1a5d849d94cf0fdbeb24a8aa5c00056dab" and "c25e8889a45946cb33e29cd563a42e42f30d90c6" have entirely different histories.
667e9c1a5d
...
c25e8889a4
@ -93,9 +93,6 @@ class LoginActivity : AppCompatActivity(), DIAware {
|
||||
}
|
||||
|
||||
private fun goToMain() {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
repository.updateApiVersion()
|
||||
}
|
||||
val intent = Intent(this, HomeActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
|
@ -41,7 +41,14 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
private var fetchedTags = false
|
||||
|
||||
init {
|
||||
// TODO: Dispatchers.IO not available in KMM, an alternative solution should be found
|
||||
connectivityStatus.start()
|
||||
if (appSettingsService.getBaseUrl() != "") {
|
||||
runBlocking {
|
||||
updateApiVersion()
|
||||
reloadBadges()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getNewerItems(): ArrayList<SelfossModel.Item> {
|
||||
@ -377,6 +384,9 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
try {
|
||||
val response = api.login()
|
||||
result = response.isSuccess == true
|
||||
if (result) {
|
||||
updateApiVersion()
|
||||
}
|
||||
} catch (cause: Throwable) {
|
||||
Napier.e(cause.stackTraceToString(), tag = "RepositoryImpl.updateRemote")
|
||||
}
|
||||
@ -390,7 +400,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
api.refreshLoginInformation()
|
||||
}
|
||||
|
||||
suspend fun updateApiVersion() {
|
||||
private suspend fun updateApiVersion() {
|
||||
val apiMajorVersion = appSettingsService.getApiVersion()
|
||||
|
||||
if (isNetworkAvailable()) {
|
||||
|
@ -24,7 +24,6 @@ class RepositoryTest() {
|
||||
private val NUMBER_ARTICLES = 100
|
||||
private val NUMBER_UNREAD = 50
|
||||
private val NUMBER_STARRED = 20
|
||||
private lateinit var repository: Repository
|
||||
|
||||
@BeforeTest
|
||||
fun setup() {
|
||||
@ -49,9 +48,10 @@ class RepositoryTest() {
|
||||
|
||||
@Test
|
||||
fun `Instantiate repository`() {
|
||||
initializeRepository()
|
||||
Repository(api, appSettingsService, connectivityStatus, db)
|
||||
|
||||
coVerify(exactly = 1) { api.version() }
|
||||
coVerify(exactly = 1) { api.stats() }
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -59,12 +59,25 @@ class RepositoryTest() {
|
||||
every { appSettingsService.getApiVersion() } returns -1
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
|
||||
initializeRepository()
|
||||
Repository(api, appSettingsService, connectivityStatus, db)
|
||||
|
||||
coVerify(exactly = 0) { api.version() }
|
||||
coVerify(exactly = 0) { api.stats() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Instantiate repository with negative stats`() {
|
||||
coEvery { api.stats() } returns SelfossModel.StatusAndData(success = true, data = SelfossModel.Stats(-100, -50, -20))
|
||||
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
|
||||
assertEquals(0, repository.badgeAll)
|
||||
assertEquals(0, repository.badgeStarred)
|
||||
assertEquals(0, repository.badgeUnread)
|
||||
coVerify(exactly = 1) { api.version() }
|
||||
coVerify(exactly = 1) { api.stats() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Get api 4 date with api 1 version stored`() {
|
||||
every { appSettingsService.getApiVersion() } returns 1
|
||||
@ -72,7 +85,7 @@ class RepositoryTest() {
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem())
|
||||
every { appSettingsService.updateApiVersion(any()) } returns Unit
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
}
|
||||
@ -90,7 +103,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameters))
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
}
|
||||
@ -103,7 +116,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem())
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
}
|
||||
@ -118,7 +131,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem())
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.displayedItems = ItemType.ALL
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
@ -134,7 +147,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem())
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.displayedItems = ItemType.STARRED
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
@ -150,7 +163,7 @@ class RepositoryTest() {
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
}
|
||||
@ -176,7 +189,7 @@ class RepositoryTest() {
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.tagFilter = SelfossModel.Tag("Test", "red", 3)
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
@ -203,7 +216,7 @@ class RepositoryTest() {
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.sourceFilter = SelfossModel.Source(1, "Test", listOf("tags"),"spouts\\rss\\fulltextrss", "", "b3aa8a664d08eb15d6ff1db2fa83e0d9.png")
|
||||
runBlocking {
|
||||
repository.getNewerItems()
|
||||
@ -219,7 +232,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem())
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.items = ArrayList(generateTestApiItem())
|
||||
runBlocking {
|
||||
repository.getOlderItems()
|
||||
@ -235,7 +248,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem())
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.items = ArrayList(generateTestApiItem())
|
||||
repository.displayedItems = ItemType.ALL
|
||||
runBlocking {
|
||||
@ -252,7 +265,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem())
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.displayedItems = ItemType.STARRED
|
||||
repository.items = ArrayList(generateTestApiItem())
|
||||
runBlocking {
|
||||
@ -268,7 +281,7 @@ class RepositoryTest() {
|
||||
fun `Reload badges`() {
|
||||
var success = false
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
success = repository.reloadBadges()
|
||||
}
|
||||
@ -287,7 +300,7 @@ class RepositoryTest() {
|
||||
|
||||
var success = false
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
success = repository.reloadBadges()
|
||||
}
|
||||
@ -308,7 +321,7 @@ class RepositoryTest() {
|
||||
|
||||
var success = false
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
success = repository.reloadBadges()
|
||||
}
|
||||
@ -329,7 +342,7 @@ class RepositoryTest() {
|
||||
|
||||
var success = false
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
runBlocking {
|
||||
success = repository.reloadBadges()
|
||||
}
|
||||
@ -354,7 +367,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns true
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag>? = null
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -377,7 +390,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns false
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag> = emptyList()
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -403,7 +416,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns true
|
||||
every { appSettingsService.isItemCachingEnabled() } returns false
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag> = emptyList()
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -426,7 +439,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns false
|
||||
every { appSettingsService.isItemCachingEnabled() } returns false
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag> = emptyList()
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -452,7 +465,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns true
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag> = emptyList()
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -477,7 +490,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isItemCachingEnabled() } returns false
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag> = emptyList()
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -501,7 +514,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns false
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag> = emptyList()
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -526,7 +539,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns false
|
||||
every { appSettingsService.isItemCachingEnabled() } returns false
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testTags: List<SelfossModel.Tag> = emptyList()
|
||||
runBlocking {
|
||||
testTags = repository.getTags()
|
||||
@ -546,7 +559,7 @@ class RepositoryTest() {
|
||||
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -568,7 +581,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isItemCachingEnabled() } returns true
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -593,7 +606,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isItemCachingEnabled() } returns false
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -615,7 +628,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isItemCachingEnabled() } returns false
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -636,7 +649,7 @@ class RepositoryTest() {
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -659,7 +672,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns true
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -682,7 +695,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns false
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -705,7 +718,7 @@ class RepositoryTest() {
|
||||
every { appSettingsService.isUpdateSourcesEnabled() } returns false
|
||||
coEvery { api.sources() } returns SelfossModel.StatusAndData(success = true, data = sources)
|
||||
every { db.sourcesQueries.sources().executeAsList() } returns sourcesDB
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var testSources: List<SelfossModel.Source>? = null
|
||||
runBlocking {
|
||||
testSources = repository.getSources()
|
||||
@ -721,7 +734,7 @@ class RepositoryTest() {
|
||||
coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.SuccessResponse(true)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "")
|
||||
@ -736,7 +749,7 @@ class RepositoryTest() {
|
||||
coEvery { api.createSourceForVersion(any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.SuccessResponse(false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "")
|
||||
@ -752,7 +765,7 @@ class RepositoryTest() {
|
||||
SelfossModel.SuccessResponse(true)
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.createSource("test", "https://test.com/feed", "spouts\\rss\\fulltextrss", "Test, New", "")
|
||||
@ -766,7 +779,7 @@ class RepositoryTest() {
|
||||
fun `delete source`() {
|
||||
coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(true)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.deleteSource(5)
|
||||
@ -780,7 +793,7 @@ class RepositoryTest() {
|
||||
fun `delete source but response fails`() {
|
||||
coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.deleteSource(5)
|
||||
@ -795,7 +808,7 @@ class RepositoryTest() {
|
||||
coEvery { api.deleteSource(any())} returns SelfossModel.SuccessResponse(false)
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.deleteSource(5)
|
||||
@ -809,7 +822,7 @@ class RepositoryTest() {
|
||||
fun `update remote`() {
|
||||
coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "finished")
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.updateRemote()
|
||||
@ -823,7 +836,7 @@ class RepositoryTest() {
|
||||
fun `update remote but response fails`() {
|
||||
coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "unallowed access")
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.updateRemote()
|
||||
@ -837,7 +850,7 @@ class RepositoryTest() {
|
||||
fun `update remote with unallowed access`() {
|
||||
coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "unallowed access")
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.updateRemote()
|
||||
@ -852,7 +865,7 @@ class RepositoryTest() {
|
||||
coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "undocumented...")
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.updateRemote()
|
||||
@ -866,7 +879,7 @@ class RepositoryTest() {
|
||||
fun login() {
|
||||
coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.login()
|
||||
@ -880,7 +893,7 @@ class RepositoryTest() {
|
||||
fun `login but response fails`() {
|
||||
coEvery { api.login() } returns SelfossModel.SuccessResponse(success = false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.login()
|
||||
@ -895,7 +908,7 @@ class RepositoryTest() {
|
||||
coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true)
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.login()
|
||||
@ -910,7 +923,7 @@ class RepositoryTest() {
|
||||
coEvery { api.refreshLoginInformation() } returns Unit
|
||||
coEvery { appSettingsService.refreshLoginInformation(any(), any(), any()) } returns Unit
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.refreshLoginInformation("https://test.com/selfoss/", "login", "password")
|
||||
|
||||
coVerify(exactly = 1) { api.refreshLoginInformation() }
|
||||
@ -930,7 +943,7 @@ class RepositoryTest() {
|
||||
SelfossModel.StatusAndData(success = true, data = generateTestApiItem(itemParameter1)),
|
||||
)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.tagFilter = SelfossModel.Tag("Tag", "read", 0)
|
||||
repository.sourceFilter = SelfossModel.Source(
|
||||
1,
|
||||
@ -953,7 +966,7 @@ class RepositoryTest() {
|
||||
coEvery { api.getItems(any(), any(), any(), any(), any(), any(), any()) } returns
|
||||
SelfossModel.StatusAndData(success = false, data = generateTestApiItem())
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.tagFilter = SelfossModel.Tag("Tag", "read", 0)
|
||||
repository.sourceFilter = SelfossModel.Source(
|
||||
1,
|
||||
@ -977,7 +990,7 @@ class RepositoryTest() {
|
||||
SelfossModel.StatusAndData(success = false, data = generateTestApiItem())
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
|
||||
initializeRepository()
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
repository.tagFilter = SelfossModel.Tag("Tag", "read", 0)
|
||||
repository.sourceFilter = SelfossModel.Source(
|
||||
1,
|
||||
@ -994,14 +1007,6 @@ class RepositoryTest() {
|
||||
|
||||
coVerify(exactly = 0) { api.getItems(any(), 0, null, null, null, null, 200) }
|
||||
}
|
||||
|
||||
fun initializeRepository() {
|
||||
repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
|
||||
runBlocking {
|
||||
repository.updateApiVersion()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List<ITEM> {
|
||||
|
Loading…
Reference in New Issue
Block a user