feat: test Identity.User for set_user_admin

This commit is contained in:
Aravinth Manivannan 2025-01-21 14:57:40 +05:30
parent f73ff9b36e
commit 1d7cc0f4f8
Signed by: realaravinth
GPG key ID: F8F50389936984FF

View file

@ -387,4 +387,29 @@ mod tests {
.when(IdentityCommand::MarkUserVerified(cmd)) .when(IdentityCommand::MarkUserVerified(cmd))
.then_expect_events(vec![expected]); .then_expect_events(vec![expected]);
} }
#[test]
fn test_user_aggregate_set_admin() {
use crate::identity::application::services::set_user_admin::{
command::*, events::*, service::*, *,
};
let cmd = SetAdminCommand::get_cmd();
let expected = UserPromotedToAdminEvent::get_event(&cmd);
let expected = IdentityEvent::UserPromotedToAdmin(expected);
let mut services = MockIdentityServicesInterface::new();
services
.expect_set_user_admin()
.times(IS_CALLED_ONLY_ONCE.unwrap())
.return_const(SetUserAdminService::mock_service(
IS_CALLED_ONLY_ONCE,
cmd.clone(),
));
UserTestFramework::with(Arc::new(services))
.given_no_previous_events()
.when(IdentityCommand::SetAdmin(cmd))
.then_expect_events(vec![expected]);
}
} }