Add id check for booking

It now checks if sales_person_id and slot_id actually exists.
This commit is contained in:
Simon Goller 2024-05-09 08:11:38 +02:00
parent 418a2944f7
commit bc8a534353
10 changed files with 201 additions and 24 deletions

View file

@ -517,3 +517,26 @@ async fn test_delete_not_found() {
let result = sales_person_service.delete(default_id(), ()).await;
test_not_found(&result, &default_id());
}
#[tokio::test]
async fn test_exists() {
let mut dependencies = build_dependencies(true, "hr");
dependencies
.sales_person_dao
.expect_find_by_id()
.with(eq(default_id()))
.returning(|_| Ok(Some(default_sales_person_entity())));
let sales_person_service = dependencies.build_service();
let result = sales_person_service.exists(default_id(), ()).await.unwrap();
assert!(result);
let mut dependencies = build_dependencies(true, "hr");
dependencies.sales_person_dao.checkpoint();
dependencies
.sales_person_dao
.expect_find_by_id()
.with(eq(default_id()))
.returning(|_| Ok(None));
let result = sales_person_service.exists(default_id(), ()).await.unwrap();
assert_eq!(false, !result);
}