diff --git a/backend/src/layer/logic/api_command/command_handler.rs b/backend/src/layer/logic/api_command/command_handler.rs index 0fe11157..150fb6c7 100644 --- a/backend/src/layer/logic/api_command/command_handler.rs +++ b/backend/src/layer/logic/api_command/command_handler.rs @@ -435,6 +435,7 @@ mod test { .unwrap(); handler.set_meal_rating(id, 1, id).await.unwrap(); handler.verify_image(id).await.unwrap(); + handler.delete_image(id).await.unwrap(); } fn get_handler() -> Result< diff --git a/backend/src/layer/trigger/api/admin.rs b/backend/src/layer/trigger/api/admin.rs index 818a6db9..2ecf300b 100644 --- a/backend/src/layer/trigger/api/admin.rs +++ b/backend/src/layer/trigger/api/admin.rs @@ -122,7 +122,10 @@ mod test { use super::ADMIN_USER; use crate::{ - layer::trigger::api::{admin::admin_router, mock::CommandMock}, + layer::trigger::api::{ + admin::admin_router, + mock::{CommandMock, FAIL_ID}, + }, util::Uuid, }; @@ -174,6 +177,16 @@ mod test { .status() ); + assert_eq!( + StatusCode::INTERNAL_SERVER_ERROR, + authed_client + .get(format!("http://{socket}/report/delete_image/{FAIL_ID}")) + .send() + .await + .unwrap() + .status() + ); + assert_eq!( StatusCode::OK, authed_client diff --git a/backend/src/layer/trigger/api/mock.rs b/backend/src/layer/trigger/api/mock.rs index d164b6aa..69a7897d 100644 --- a/backend/src/layer/trigger/api/mock.rs +++ b/backend/src/layer/trigger/api/mock.rs @@ -299,6 +299,7 @@ impl RequestDataAccess for RequestDatabaseMock { } } +pub const FAIL_ID: Uuid = Uuid::from_u128(12345); pub struct CommandMock; #[async_trait] @@ -355,8 +356,14 @@ impl Command for CommandMock { Ok(()) } - async fn delete_image(&self, _image_id: Uuid) -> CommandResult<()> { - Ok(()) + async fn delete_image(&self, image_id: Uuid) -> CommandResult<()> { + if image_id == FAIL_ID { + Err(crate::interface::api_command::CommandError::DataError( + crate::interface::persistent_data::DataError::NoSuchItem, + )) + } else { + Ok(()) + } } async fn verify_image(&self, _image_id: Uuid) -> CommandResult<()> {