Skip to content

Commit

Permalink
missed test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
worldofjoni committed Jul 14, 2024
1 parent 1dca470 commit 0723790
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions backend/src/layer/logic/api_command/command_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down
15 changes: 14 additions & 1 deletion backend/src/layer/trigger/api/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions backend/src/layer/trigger/api/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ impl RequestDataAccess for RequestDatabaseMock {
}
}

pub const FAIL_ID: Uuid = Uuid::from_u128(12345);
pub struct CommandMock;

#[async_trait]
Expand Down Expand Up @@ -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<()> {
Expand Down

0 comments on commit 0723790

Please sign in to comment.