feat: define store_name_exists port for identity
This commit is contained in:
parent
176e9ff6f6
commit
e52530f0e3
3 changed files with 58 additions and 0 deletions
|
@ -18,4 +18,7 @@ pub enum OutDBPortError {
|
|||
PhoneNumberNotFound,
|
||||
EmpLoginOTPNotFound,
|
||||
EmpVerificationOTPNotFound,
|
||||
DuplicateStoreName,
|
||||
DuplicateStoreID,
|
||||
StoreIDNotFound,
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ pub mod get_verification_secret;
|
|||
pub mod invite_id_exists;
|
||||
pub mod phone_exists;
|
||||
pub mod store_id_exists;
|
||||
pub mod store_name_exists;
|
||||
pub mod user_id_exists;
|
||||
//pub mod verification_otp_exists;
|
||||
pub mod verification_secret_exists;
|
||||
|
|
54
src/identity/application/port/output/db/store_name_exists.rs
Normal file
54
src/identity/application/port/output/db/store_name_exists.rs
Normal file
|
@ -0,0 +1,54 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
|
||||
use crate::identity::domain::store_aggregate::Store;
|
||||
|
||||
use super::errors::*;
|
||||
#[cfg(test)]
|
||||
#[allow(unused_imports)]
|
||||
pub use tests::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait StoreNameExistsDBPort: Send + Sync {
|
||||
async fn store_name_exists(&self, s: &Store) -> OutDBPortResult<bool>;
|
||||
}
|
||||
|
||||
pub type StoreNameExistsDBPortObj = std::sync::Arc<dyn StoreNameExistsDBPort>;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn mock_store_name_exists_db_port_false(times: Option<usize>) -> StoreNameExistsDBPortObj {
|
||||
let mut m = MockStoreNameExistsDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_store_name_exists()
|
||||
.times(times)
|
||||
.returning(|_| Ok(false));
|
||||
} else {
|
||||
m.expect_store_name_exists().returning(|_| Ok(false));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
|
||||
pub fn mock_store_name_exists_db_port_true(times: Option<usize>) -> StoreNameExistsDBPortObj {
|
||||
let mut m = MockStoreNameExistsDBPort::new();
|
||||
if let Some(times) = times {
|
||||
m.expect_store_name_exists()
|
||||
.times(times)
|
||||
.returning(|_| Ok(true));
|
||||
} else {
|
||||
m.expect_store_name_exists().returning(|_| Ok(true));
|
||||
}
|
||||
|
||||
Arc::new(m)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue