feat: define service group and UserServicesInterface with mocking
This commit is contained in:
parent
1f25754822
commit
86a66a420c
1 changed files with 58 additions and 0 deletions
|
@ -2,6 +2,9 @@
|
|||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
use derive_builder::Builder;
|
||||
use mockall::predicate::*;
|
||||
use mockall::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
mod delete_user;
|
||||
|
@ -35,3 +38,58 @@ pub enum UserCommand {
|
|||
SetAdmin(SetAdminCommand),
|
||||
ResendVerificationEmail(ResendVerificationEmailCommand),
|
||||
}
|
||||
|
||||
#[automock]
|
||||
pub trait UserServicesInterface: Send + Sync {
|
||||
fn delete_user(&self) -> delete_user::DeleteUserServiceObj;
|
||||
fn login(&self) -> login::LoginServiceObj;
|
||||
fn mark_user_verified(&self) -> mark_user_verified::MarkUserVerifiedServiceObj;
|
||||
fn register_user(&self) -> register_user::RegisterUserServiceObj;
|
||||
fn resend_verification_email(
|
||||
&self,
|
||||
) -> resend_verification_email::ResendVerificationEmailServiceObj;
|
||||
fn set_user_admin(&self) -> set_user_admin::SetUserAdminServiceObj;
|
||||
fn update_email(&self) -> update_email::UpdateEmailServiceObj;
|
||||
fn update_password(&self) -> update_password::UpdatePasswordServiceObj;
|
||||
}
|
||||
|
||||
#[derive(Clone, Builder)]
|
||||
pub struct UserServices {
|
||||
delete_user: delete_user::DeleteUserServiceObj,
|
||||
login: login::LoginServiceObj,
|
||||
mark_user_verified: mark_user_verified::MarkUserVerifiedServiceObj,
|
||||
register_user: register_user::RegisterUserServiceObj,
|
||||
resend_verification_email: resend_verification_email::ResendVerificationEmailServiceObj,
|
||||
set_user_admin: set_user_admin::SetUserAdminServiceObj,
|
||||
update_email: update_email::UpdateEmailServiceObj,
|
||||
update_password: update_password::UpdatePasswordServiceObj,
|
||||
}
|
||||
|
||||
impl UserServicesInterface for UserServices {
|
||||
fn delete_user(&self) -> delete_user::DeleteUserServiceObj {
|
||||
self.delete_user.clone()
|
||||
}
|
||||
fn login(&self) -> login::LoginServiceObj {
|
||||
self.login.clone()
|
||||
}
|
||||
fn mark_user_verified(&self) -> mark_user_verified::MarkUserVerifiedServiceObj {
|
||||
self.mark_user_verified.clone()
|
||||
}
|
||||
fn register_user(&self) -> register_user::RegisterUserServiceObj {
|
||||
self.register_user.clone()
|
||||
}
|
||||
fn resend_verification_email(
|
||||
&self,
|
||||
) -> resend_verification_email::ResendVerificationEmailServiceObj {
|
||||
self.resend_verification_email.clone()
|
||||
}
|
||||
fn set_user_admin(&self) -> set_user_admin::SetUserAdminServiceObj {
|
||||
self.set_user_admin.clone()
|
||||
}
|
||||
fn update_email(&self) -> update_email::UpdateEmailServiceObj {
|
||||
self.update_email.clone()
|
||||
}
|
||||
fn update_password(&self) -> update_password::UpdatePasswordServiceObj {
|
||||
self.update_password.clone()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue