fix: accept product_id separately

This commit is contained in:
Aravinth Manivannan 2024-07-16 11:36:49 +05:30
parent 37aeac8c69
commit 4fc4b612bf
Signed by: realaravinth
GPG key ID: F8F50389936984FF
2 changed files with 7 additions and 5 deletions

View file

@ -4,6 +4,7 @@
use mockall::predicate::*; use mockall::predicate::*;
use mockall::*; use mockall::*;
use uuid::Uuid;
use crate::inventory::domain::product_aggregate::Customization; use crate::inventory::domain::product_aggregate::Customization;
@ -18,6 +19,7 @@ pub trait CustomizationNameExistsForProductDBPort: Send + Sync {
async fn customization_name_exists_for_product( async fn customization_name_exists_for_product(
&self, &self,
c: &Customization, c: &Customization,
product_id: &Uuid,
) -> InventoryDBResult<bool>; ) -> InventoryDBResult<bool>;
} }
@ -37,10 +39,10 @@ pub mod tests {
if let Some(times) = times { if let Some(times) = times {
m.expect_customization_name_exists_for_product() m.expect_customization_name_exists_for_product()
.times(times) .times(times)
.returning(|_| Ok(false)); .returning(|_, _| Ok(false));
} else { } else {
m.expect_customization_name_exists_for_product() m.expect_customization_name_exists_for_product()
.returning(|_| Ok(false)); .returning(|_, _| Ok(false));
} }
Arc::new(m) Arc::new(m)
@ -53,10 +55,10 @@ pub mod tests {
if let Some(times) = times { if let Some(times) = times {
m.expect_customization_name_exists_for_product() m.expect_customization_name_exists_for_product()
.times(times) .times(times)
.returning(|_| Ok(true)); .returning(|_, _| Ok(true));
} else { } else {
m.expect_customization_name_exists_for_product() m.expect_customization_name_exists_for_product()
.returning(|_| Ok(true)); .returning(|_, _| Ok(true));
} }
Arc::new(m) Arc::new(m)

View file

@ -84,7 +84,7 @@ impl AddProductUseCase for AddProductService {
if self if self
.db_customization_name_exists_for_product .db_customization_name_exists_for_product
.customization_name_exists_for_product(&customization) .customization_name_exists_for_product(&customization, &product_id)
.await? .await?
{ {
return Err(InventoryError::DuplicateCustomizationName); return Err(InventoryError::DuplicateCustomizationName);