diff --git a/src/inventory/application/port/output/db/customization_id_exists.rs b/src/inventory/application/port/output/db/customization_id_exists.rs new file mode 100644 index 0000000..a5bf068 --- /dev/null +++ b/src/inventory/application/port/output/db/customization_id_exists.rs @@ -0,0 +1,57 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use mockall::predicate::*; +use mockall::*; +use uuid::Uuid; + +use super::errors::*; +#[cfg(test)] +#[allow(unused_imports)] +pub use tests::*; + +#[automock] +#[async_trait::async_trait] +pub trait CustomizationIDExistsDBPort: Send + Sync { + async fn customization_id_exists(&self, c: &Uuid) -> InventoryDBResult; +} + +pub type CustomizationIDExistsDBPortObj = std::sync::Arc; + +#[cfg(test)] +pub mod tests { + use super::*; + + use std::sync::Arc; + + pub fn mock_customization_id_exists_db_port_false( + times: Option, + ) -> CustomizationIDExistsDBPortObj { + let mut m = MockCustomizationIDExistsDBPort::new(); + if let Some(times) = times { + m.expect_customization_id_exists() + .times(times) + .returning(|_| Ok(false)); + } else { + m.expect_customization_id_exists().returning(|_| Ok(false)); + } + + Arc::new(m) + } + + pub fn mock_customization_id_exists_db_port_true( + times: Option, + ) -> CustomizationIDExistsDBPortObj { + let mut m = MockCustomizationIDExistsDBPort::new(); + if let Some(times) = times { + m.expect_customization_id_exists() + .times(times) + .returning(|_| Ok(true)); + } else { + m.expect_customization_id_exists().returning(|_| Ok(true)); + } + + Arc::new(m) + } +}