feat: mock resend_verification_email service and test init utils for cmd and event
This commit is contained in:
parent
1d7cc0f4f8
commit
8b6f5f0acb
3 changed files with 34 additions and 0 deletions
|
@ -53,4 +53,15 @@ mod tests {
|
|||
Some(IdentityCommandError::BadEmail)
|
||||
);
|
||||
}
|
||||
|
||||
impl ResendVerificationEmailCommand {
|
||||
pub fn get_cmd() -> Self {
|
||||
let u = crate::identity::domain::aggregate::User::default();
|
||||
Self {
|
||||
user_id: *u.user_id(),
|
||||
first_name: u.first_name().clone(),
|
||||
email: u.email().clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
|
||||
pub mod command;
|
||||
pub mod service;
|
||||
|
||||
use super::errors::*;
|
||||
|
||||
#[automock]
|
||||
#[async_trait::async_trait]
|
||||
pub trait ResendVerificationEmailUseCase: Send + Sync {
|
||||
async fn resend_verification_email(
|
||||
|
|
|
@ -116,4 +116,24 @@ mod tests {
|
|||
Some(IdentityError::DuplicateEmail)
|
||||
);
|
||||
}
|
||||
|
||||
impl ResendVerificationEmailService {
|
||||
pub fn mock_service(
|
||||
times: Option<usize>,
|
||||
cmd: command::ResendVerificationEmailCommand,
|
||||
) -> ResendVerificationEmailServiceObj {
|
||||
let mut m = MockResendVerificationEmailUseCase::default();
|
||||
let res = ();
|
||||
|
||||
if let Some(times) = times {
|
||||
m.expect_resend_verification_email()
|
||||
.times(times)
|
||||
.return_const(Ok(res));
|
||||
} else {
|
||||
m.expect_resend_verification_email().return_const(Ok(res));
|
||||
}
|
||||
|
||||
std::sync::Arc::new(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue