Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
Revert app/src/test/java/gq/kirmanak/mealient/data/network/MealieData…
Browse files Browse the repository at this point in the history
…SourceWrapperTest.kt
  • Loading branch information
sweep-ai[bot] authored Feb 21, 2024
1 parent 559a686 commit 4b64a90
Showing 1 changed file with 5 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,11 @@ class MealieDataSourceWrapperTest : BaseUnitTest() {
assertThat(actual).isEqualTo(listOf(RECIPE_SUMMARY_PORRIDGE))
}

@Test
fun `when updateRecipe fails expect exception`() = runTest {
val slug = "porridge"
coEvery { dataSource.createRecipe(any()) } returns slug
coEvery { dataSource.updateRecipe(any(), any()) } throws IOException()
@Test(expected = IOException::class)
fun `when request fails expect createRecipe to rethrow`() = runTest {
coEvery { dataSource.createRecipe(any()) } throws IOException()
coEvery { authRepo.getAuthToken() } returns TEST_TOKEN

assertThrows(IOException::class.java) {
subject.addRecipe(PORRIDGE_ADD_RECIPE_INFO)
}

coVerify(exactly = 1) { dataSource.createRecipe(any()) }
coVerify(exactly = 1) { dataSource.updateRecipe(any(), any()) }
subject.addRecipe(PORRIDGE_ADD_RECIPE_INFO)
}

@Test
Expand Down Expand Up @@ -143,23 +135,4 @@ class MealieDataSourceWrapperTest : BaseUnitTest() {
fun `when get favorite recipes expect correct result`() = runTest {
assertThat(subject.getFavoriteRecipes()).isEqualTo(FAVORITE_RECIPES_LIST)
}
}
@Test
fun deleteRecipe_expectCorrectNetworkCall() = runTest {
val recipeSlug = "test-recipe"
coEvery { dataSource.deleteRecipe(recipeSlug) } just Runs

subject.deleteRecipe(recipeSlug)

coVerify(exactly = 1) { dataSource.deleteRecipe(recipeSlug) }
}

@Test(expected = IOException::class)
fun deleteRecipe_whenNetworkFails_expectException() = runTest {
val recipeSlug = "test-recipe"
coEvery { dataSource.deleteRecipe(recipeSlug) } throws IOException()

subject.deleteRecipe(recipeSlug)

coVerify(exactly = 1) { dataSource.deleteRecipe(recipeSlug) }
}
}

0 comments on commit 4b64a90

Please sign in to comment.