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

View file

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