diff --git a/src/identity/application/port/output/db/email_exists.rs b/src/identity/application/port/output/db/email_exists.rs new file mode 100644 index 0000000..7a28fee --- /dev/null +++ b/src/identity/application/port/output/db/email_exists.rs @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2024 Aravinth Manivannan +// +// SPDX-License-Identifier: AGPL-3.0-or-later + +use mockall::predicate::*; +use mockall::*; + +use super::errors::*; + +#[cfg(test)] +#[allow(unused_imports)] +pub use tests::*; + +#[automock] +#[async_trait::async_trait] +pub trait EmailExistsOutDBPort: Send + Sync { + async fn email_exists(&self, email: &str) -> OutDBPortResult; +} + +pub type EmailExistsOutDBPortObj = std::sync::Arc; + +#[cfg(test)] +pub mod tests { + use super::*; + + use std::sync::Arc; + + pub fn mock_email_exists_db_port( + times: Option, + returning: bool, + ) -> EmailExistsOutDBPortObj { + let mut m = MockEmailExistsOutDBPort::new(); + if let Some(times) = times { + m.expect_email_exists() + .times(times) + .returning(move |_| Ok(returning)); + } else { + m.expect_email_exists().returning(move |_| Ok(returning)); + } + + Arc::new(m) + } +}