Remove unused data
This commit is contained in:
@@ -3,10 +3,6 @@ package gq.kirmanak.mealient.data.recipes.db
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import gq.kirmanak.mealient.database.AppDb
|
||||
import gq.kirmanak.mealient.database.recipe.entity.CategoryEntity
|
||||
import gq.kirmanak.mealient.database.recipe.entity.CategoryRecipeEntity
|
||||
import gq.kirmanak.mealient.database.recipe.entity.TagEntity
|
||||
import gq.kirmanak.mealient.database.recipe.entity.TagRecipeEntity
|
||||
import gq.kirmanak.mealient.test.HiltRobolectricTest
|
||||
import gq.kirmanak.mealient.test.RecipeImplTestData.BREAD_INGREDIENT
|
||||
import gq.kirmanak.mealient.test.RecipeImplTestData.CAKE_BREAD_RECIPE_INGREDIENT_ENTITY
|
||||
@@ -36,28 +32,6 @@ class RecipeStorageImplTest : HiltRobolectricTest() {
|
||||
@Inject
|
||||
lateinit var appDb: AppDb
|
||||
|
||||
@Test
|
||||
fun `when saveRecipes then saves tags`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
val actualTags = appDb.recipeDao().queryAllTags()
|
||||
assertThat(actualTags).containsExactly(
|
||||
TagEntity(localId = 1, name = "gluten"),
|
||||
TagEntity(localId = 2, name = "allergic"),
|
||||
TagEntity(localId = 3, name = "milk")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when saveRecipes then saves categories`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
val actual = appDb.recipeDao().queryAllCategories()
|
||||
assertThat(actual).containsExactly(
|
||||
CategoryEntity(localId = 1, name = "dessert"),
|
||||
CategoryEntity(localId = 2, name = "tasty"),
|
||||
CategoryEntity(localId = 3, name = "porridge")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when saveRecipes then saves recipes`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
@@ -68,30 +42,6 @@ class RecipeStorageImplTest : HiltRobolectricTest() {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when saveRecipes then saves category recipes`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
val actual = appDb.recipeDao().queryAllCategoryRecipes()
|
||||
assertThat(actual).containsExactly(
|
||||
CategoryRecipeEntity(categoryId = 1, recipeId = "1"),
|
||||
CategoryRecipeEntity(categoryId = 2, recipeId = "1"),
|
||||
CategoryRecipeEntity(categoryId = 3, recipeId = "2"),
|
||||
CategoryRecipeEntity(categoryId = 2, recipeId = "2")
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when saveRecipes then saves tag recipes`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
val actual = appDb.recipeDao().queryAllTagRecipes()
|
||||
assertThat(actual).containsExactly(
|
||||
TagRecipeEntity(tagId = 1, recipeId = "1"),
|
||||
TagRecipeEntity(tagId = 2, recipeId = "1"),
|
||||
TagRecipeEntity(tagId = 3, recipeId = "2"),
|
||||
TagRecipeEntity(tagId = 1, recipeId = "2"),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when refreshAll then old recipes aren't preserved`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
@@ -100,28 +50,6 @@ class RecipeStorageImplTest : HiltRobolectricTest() {
|
||||
assertThat(actual).containsExactly(CAKE_RECIPE_SUMMARY_ENTITY)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when refreshAll then old category recipes aren't preserved`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
subject.refreshAll(listOf(RECIPE_SUMMARY_CAKE))
|
||||
val actual = appDb.recipeDao().queryAllCategoryRecipes()
|
||||
assertThat(actual).containsExactly(
|
||||
CategoryRecipeEntity(categoryId = 1, recipeId = "1"),
|
||||
CategoryRecipeEntity(categoryId = 2, recipeId = "1"),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when refreshAll then old tag recipes aren't preserved`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
subject.refreshAll(listOf(RECIPE_SUMMARY_CAKE))
|
||||
val actual = appDb.recipeDao().queryAllTagRecipes()
|
||||
assertThat(actual).containsExactly(
|
||||
TagRecipeEntity(tagId = 1, recipeId = "1"),
|
||||
TagRecipeEntity(tagId = 2, recipeId = "1"),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when clearAllLocalData then recipes aren't preserved`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
@@ -130,22 +58,6 @@ class RecipeStorageImplTest : HiltRobolectricTest() {
|
||||
assertThat(actual).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when clearAllLocalData then categories aren't preserved`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
subject.clearAllLocalData()
|
||||
val actual = appDb.recipeDao().queryAllCategories()
|
||||
assertThat(actual).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when clearAllLocalData then tags aren't preserved`() = runTest {
|
||||
subject.saveRecipes(TEST_RECIPE_SUMMARIES)
|
||||
subject.clearAllLocalData()
|
||||
val actual = appDb.recipeDao().queryAllTags()
|
||||
assertThat(actual).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when saveRecipeInfo then saves recipe info`() = runTest {
|
||||
subject.saveRecipes(listOf(RECIPE_SUMMARY_CAKE))
|
||||
|
||||
@@ -13,11 +13,7 @@ object RecipeImplTestData {
|
||||
remoteId = "1",
|
||||
name = "Cake",
|
||||
slug = "cake",
|
||||
image = "86",
|
||||
description = "A tasty cake",
|
||||
recipeCategories = listOf("dessert", "tasty"),
|
||||
tags = listOf("gluten", "allergic"),
|
||||
rating = 4,
|
||||
dateAdded = LocalDate.parse("2021-11-13"),
|
||||
dateUpdated = LocalDateTime.parse("2021-11-13T15:30:13"),
|
||||
imageId = "cake",
|
||||
@@ -27,11 +23,7 @@ object RecipeImplTestData {
|
||||
remoteId = "2",
|
||||
name = "Porridge",
|
||||
slug = "porridge",
|
||||
image = "89",
|
||||
description = "A tasty porridge",
|
||||
recipeCategories = listOf("porridge", "tasty"),
|
||||
tags = listOf("gluten", "milk"),
|
||||
rating = 5,
|
||||
dateAdded = LocalDate.parse("2021-11-12"),
|
||||
dateUpdated = LocalDateTime.parse("2021-10-13T17:35:23"),
|
||||
imageId = "porridge",
|
||||
@@ -43,9 +35,7 @@ object RecipeImplTestData {
|
||||
remoteId = "1",
|
||||
name = "Cake",
|
||||
slug = "cake",
|
||||
image = "86",
|
||||
description = "A tasty cake",
|
||||
rating = 4,
|
||||
dateAdded = LocalDate.parse("2021-11-13"),
|
||||
dateUpdated = LocalDateTime.parse("2021-11-13T15:30:13"),
|
||||
imageId = "cake",
|
||||
@@ -55,9 +45,7 @@ object RecipeImplTestData {
|
||||
remoteId = "2",
|
||||
name = "Porridge",
|
||||
slug = "porridge",
|
||||
image = "89",
|
||||
description = "A tasty porridge",
|
||||
rating = 5,
|
||||
dateAdded = LocalDate.parse("2021-11-12"),
|
||||
dateUpdated = LocalDateTime.parse("2021-10-13T17:35:23"),
|
||||
imageId = "porridge",
|
||||
|
||||
Reference in New Issue
Block a user