Repository Unit Tests #50
@ -352,7 +352,7 @@ class Repository(private val api: SelfossApi, private val appSettingsService: Ap
|
||||
|
||||
suspend fun updateRemote(): Boolean {
|
||||
return if (isNetworkAvailable()) {
|
||||
api.update().equals("finished")
|
||||
api.update().data.equals("finished")
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -718,12 +718,26 @@ class RepositoryTest() {
|
||||
}
|
||||
AmineB marked this conversation as resolved
Outdated
|
||||
|
||||
coVerify(exactly = 1) { api.update() }
|
||||
assertSame(true, response)
|
||||
assertTrue(response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `update remote but response fails`() {
|
||||
coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "undocumented...")
|
||||
coEvery { api.update()} returns SelfossModel.StatusAndData(success = false, data = "unallowed access")
|
||||
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.updateRemote()
|
||||
}
|
||||
|
||||
coVerify(exactly = 1) { api.update() }
|
||||
assertSame(false, response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `update remote with unallowed access`() {
|
||||
coEvery { api.update()} returns SelfossModel.StatusAndData(success = true, data = "unallowed access")
|
||||
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
AmineB marked this conversation as resolved
Outdated
AmineB
commented
This should be This should be `coVerify(exactly = 3) { api.getItems(any(), 0, "Tag", 1, "search", null, 200) }`
davidoskky
commented
As above As above
AmineB
commented
As above. I don't know what you wanted to test. The thing is, passing null, null, null, null in the function will make it fail, because in your calls, you pass data. As above.
I don't know what you wanted to test.
The thing is, passing null, null, null, null in the function will make it fail, because in your calls, you pass data.
|
||||
var response = false
|
||||
|
Loading…
Reference in New Issue
Block a user
tryToCacheItemsAndGetNewOnes
will only return1
item as it only returns new items.You will also need to add
every { db.itemsQueries.transaction(any(), any()) } returns Unit
to the setup.