44 lines
1.1 KiB
Rust
44 lines
1.1 KiB
Rust
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
use mockall::predicate::*;
|
|
use mockall::*;
|
|
|
|
use super::errors::*;
|
|
use crate::identity::domain::employee_aggregate::*;
|
|
|
|
#[cfg(test)]
|
|
#[allow(unused_imports)]
|
|
pub use tests::*;
|
|
|
|
#[automock]
|
|
#[async_trait::async_trait]
|
|
pub trait PhoneNumberExistsOutDBPort: Send + Sync {
|
|
async fn phone_exists(&self, phone: &PhoneNumber) -> OutDBPortResult<bool>;
|
|
}
|
|
|
|
pub type PhoneNumberExistsOutDBPortObj = std::sync::Arc<dyn PhoneNumberExistsOutDBPort>;
|
|
|
|
#[cfg(test)]
|
|
pub mod tests {
|
|
use super::*;
|
|
|
|
use std::sync::Arc;
|
|
|
|
pub fn mock_phone_exists_db_port(
|
|
times: Option<usize>,
|
|
returning: bool,
|
|
) -> PhoneNumberExistsOutDBPortObj {
|
|
let mut m = MockPhoneNumberExistsOutDBPort::new();
|
|
if let Some(times) = times {
|
|
m.expect_phone_exists()
|
|
.times(times)
|
|
.returning(move |_| Ok(returning));
|
|
} else {
|
|
m.expect_phone_exists().returning(move |_| Ok(returning));
|
|
}
|
|
|
|
Arc::new(m)
|
|
}
|
|
}
|