feat: db: email_exists port
This commit is contained in:
parent
c8edab57a8
commit
d1d87fa28c
1 changed files with 43 additions and 0 deletions
43
src/identity/application/port/output/db/email_exists.rs
Normal file
43
src/identity/application/port/output/db/email_exists.rs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// 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<bool>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type EmailExistsOutDBPortObj = std::sync::Arc<dyn EmailExistsOutDBPort>;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub fn mock_email_exists_db_port(
|
||||||
|
times: Option<usize>,
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue