Fix RemoteToLocalMappingsTest compilation
This commit is contained in:
24
.run/Run tests.run.xml
Normal file
24
.run/Run tests.run.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration name="Run tests" default="false" factoryName="Gradle"
|
||||||
|
type="GradleRunConfiguration">
|
||||||
|
<ExternalSystemSettings>
|
||||||
|
<option name="executionName" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="externalSystemIdString" value="GRADLE" />
|
||||||
|
<option name="scriptParameters" value="" />
|
||||||
|
<option name="taskDescriptions">
|
||||||
|
<list />
|
||||||
|
</option>
|
||||||
|
<option name="taskNames">
|
||||||
|
<list>
|
||||||
|
<option value="testDebugUnitTest" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
<option name="vmOptions" />
|
||||||
|
</ExternalSystemSettings>
|
||||||
|
<ExternalSystemDebugServerProcess>false</ExternalSystemDebugServerProcess>
|
||||||
|
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
|
||||||
|
<DebugAllEnabled>false</DebugAllEnabled>
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
@@ -2,13 +2,11 @@ package gq.kirmanak.mealient.data.auth.impl
|
|||||||
|
|
||||||
import gq.kirmanak.mealient.data.auth.AuthDataSource
|
import gq.kirmanak.mealient.data.auth.AuthDataSource
|
||||||
import gq.kirmanak.mealient.datasource.MealieDataSource
|
import gq.kirmanak.mealient.datasource.MealieDataSource
|
||||||
import gq.kirmanak.mealient.logging.Logger
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class AuthDataSourceImpl @Inject constructor(
|
class AuthDataSourceImpl @Inject constructor(
|
||||||
private val logger: Logger,
|
|
||||||
private val mealieDataSource: MealieDataSource,
|
private val mealieDataSource: MealieDataSource,
|
||||||
) : AuthDataSource {
|
) : AuthDataSource {
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
package gq.kirmanak.mealient.data.add.impl
|
|
||||||
|
|
||||||
import com.google.common.truth.Truth.assertThat
|
|
||||||
import gq.kirmanak.mealient.data.add.models.AddRecipeRequest
|
|
||||||
import gq.kirmanak.mealient.data.network.NetworkError
|
|
||||||
import gq.kirmanak.mealient.data.network.ServiceFactory
|
|
||||||
import gq.kirmanak.mealient.logging.Logger
|
|
||||||
import io.mockk.MockKAnnotations
|
|
||||||
import io.mockk.coEvery
|
|
||||||
import io.mockk.impl.annotations.MockK
|
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
|
||||||
import kotlinx.coroutines.test.runTest
|
|
||||||
import kotlinx.serialization.SerializationException
|
|
||||||
import org.junit.Before
|
|
||||||
import org.junit.Test
|
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
|
||||||
class AddRecipeDataSourceImplTest {
|
|
||||||
|
|
||||||
@MockK
|
|
||||||
lateinit var serviceProvider: ServiceFactory<AddRecipeService>
|
|
||||||
|
|
||||||
@MockK
|
|
||||||
lateinit var service: AddRecipeService
|
|
||||||
|
|
||||||
@MockK(relaxUnitFun = true)
|
|
||||||
lateinit var logger: Logger
|
|
||||||
|
|
||||||
lateinit var subject: AddRecipeDataSourceImpl
|
|
||||||
|
|
||||||
@Before
|
|
||||||
fun setUp() {
|
|
||||||
MockKAnnotations.init(this)
|
|
||||||
coEvery { serviceProvider.provideService(any()) } returns service
|
|
||||||
subject = AddRecipeDataSourceImpl(serviceProvider, logger)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = NetworkError.NotMealie::class)
|
|
||||||
fun `when addRecipe fails then maps error`() = runTest {
|
|
||||||
coEvery { service.addRecipe(any()) } throws SerializationException()
|
|
||||||
subject.addRecipe(AddRecipeRequest())
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `when addRecipe succeeds then returns response`() = runTest {
|
|
||||||
coEvery { service.addRecipe(any()) } returns "response"
|
|
||||||
assertThat(subject.addRecipe(AddRecipeRequest())).isEqualTo("response")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +1,17 @@
|
|||||||
package gq.kirmanak.mealient.data.add.models
|
package gq.kirmanak.mealient.extensions
|
||||||
|
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
|
import gq.kirmanak.mealient.datasource.models.AddRecipeIngredient
|
||||||
|
import gq.kirmanak.mealient.datasource.models.AddRecipeInstruction
|
||||||
|
import gq.kirmanak.mealient.datasource.models.AddRecipeRequest
|
||||||
|
import gq.kirmanak.mealient.datasource.models.AddRecipeSettings
|
||||||
import gq.kirmanak.mealient.datastore.recipe.AddRecipeDraft
|
import gq.kirmanak.mealient.datastore.recipe.AddRecipeDraft
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class AddRecipeRequestTest {
|
class RemoteToLocalMappingsTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `when construct from input then fills fields correctly`() {
|
fun `when toAddRecipeRequest then fills fields correctly`() {
|
||||||
val input = AddRecipeDraft(
|
val input = AddRecipeDraft(
|
||||||
recipeName = "Recipe name",
|
recipeName = "Recipe name",
|
||||||
recipeDescription = "Recipe description",
|
recipeDescription = "Recipe description",
|
||||||
@@ -36,11 +40,11 @@ class AddRecipeRequestTest {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
assertThat(AddRecipeRequest(input)).isEqualTo(expected)
|
assertThat(input.toAddRecipeRequest()).isEqualTo(expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `when toInput then fills fields correctly`() {
|
fun `when toDraft then fills fields correctly`() {
|
||||||
val request = AddRecipeRequest(
|
val request = AddRecipeRequest(
|
||||||
name = "Recipe name",
|
name = "Recipe name",
|
||||||
description = "Recipe description",
|
description = "Recipe description",
|
||||||
Reference in New Issue
Block a user