Issue#11 Fix codeAnalysis errors

This commit is contained in:
Gergely Hegedus 2022-01-23 22:45:25 +02:00
parent 8ae94cfe92
commit b52652ed67
6 changed files with 21 additions and 28 deletions

View file

@ -56,23 +56,21 @@ internal class FavouriteContentLocalStorageImplTest : KoinTest {
/** GIVEN content_id added WHEN removed to Favourite THEN it no longer can be read out */
@Test
fun contentIdAddedThenRemovedCanNoLongerBeReadOut() = runTest(testDispatcher) {
val expected = listOf<ContentId>()
sut.markAsFavourite(ContentId("b"))
val expected = listOf<ContentId>()
sut.markAsFavourite(ContentId("b"))
sut.deleteAsFavourite(ContentId("b"))
val actual = sut.observeFavourites().first()
sut.deleteAsFavourite(ContentId("b"))
val actual = sut.observeFavourites().first()
Assert.assertEquals(expected, actual)
}
Assert.assertEquals(expected, actual)
}
/** GIVEN empty database WHILE observing content WHEN favourite added THEN change is emitted */
@Test
fun addingFavouriteUpdatesExistingObservers() = runTest(testDispatcher) {
val expected = listOf(listOf(), listOf(ContentId("a")))
val actual = async(coroutineContext) {
sut.observeFavourites().take(2).toList()
}
val actual = async(coroutineContext) { sut.observeFavourites().take(2).toList() }
advanceUntilIdle()
sut.markAsFavourite(ContentId("a"))
@ -84,17 +82,17 @@ internal class FavouriteContentLocalStorageImplTest : KoinTest {
/** GIVEN non empty database WHILE observing content WHEN favourite removed THEN change is emitted */
@Test
fun removingFavouriteUpdatesExistingObservers() = runTest(testDispatcher) {
val expected = listOf(listOf(ContentId("a")), listOf())
sut.markAsFavourite(ContentId("a"))
val expected = listOf(listOf(ContentId("a")), listOf())
sut.markAsFavourite(ContentId("a"))
val actual = async(coroutineContext) {
sut.observeFavourites().take(2).toList()
}
advanceUntilIdle()
sut.deleteAsFavourite(ContentId("a"))
val actual = async(coroutineContext) {
sut.observeFavourites().take(2).toList()
}
advanceUntilIdle()
Assert.assertEquals(expected, actual.getCompleted())
}
sut.deleteAsFavourite(ContentId("a"))
advanceUntilIdle()
Assert.assertEquals(expected, actual.getCompleted())
}
}

View file

@ -4,7 +4,6 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runTest
import org.fnives.test.showcase.core.storage.content.FavouriteContentLocalStorage
import org.fnives.test.showcase.model.content.ContentId
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName

View file

@ -1,11 +1,9 @@
package org.fnives.test.showcase.core.content
import app.cash.turbine.test
import kotlinx.coroutines.async
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.runTest
import org.fnives.test.showcase.core.storage.content.FavouriteContentLocalStorage
import org.fnives.test.showcase.model.content.Content

View file

@ -1,7 +1,6 @@
package org.fnives.test.showcase.core.content
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.runTest
import org.fnives.test.showcase.core.storage.content.FavouriteContentLocalStorage
import org.fnives.test.showcase.model.content.ContentId

View file

@ -1,6 +1,5 @@
package org.fnives.test.showcase.core.login.koin
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.runTest
import org.fnives.test.showcase.core.content.ContentRepository
import org.fnives.test.showcase.core.di.koin.createCoreModule

View file

@ -1,11 +1,11 @@
project.ext {
androidx_core_version = "1.7.0"
androidx_appcompat_version = "1.4.0"
androidx_material_version = "1.4.0"
androidx_constraintlayout_version = "2.1.2"
androidx_appcompat_version = "1.4.1"
androidx_material_version = "1.5.0"
androidx_constraintlayout_version = "2.1.3"
androidx_livedata_version = "2.4.0"
androidx_swiperefreshlayout_version = "1.1.0"
androidx_room_version = "2.4.0"
androidx_room_version = "2.4.1"
activity_ktx_version = "1.4.0"
coroutines_version = "1.6.0"