app: add organization + sharing commands/queries

This commit is contained in:
2026-05-31 05:17:51 +02:00
parent 536bf3463a
commit d1394ce7bb
29 changed files with 740 additions and 1 deletions

View File

@@ -0,0 +1,47 @@
use std::sync::Arc;
use application::testing::{InMemoryShareRepository, StubEventPublisher};
use application::sharing::{ShareResourceCommand, ShareResourceHandler};
use domain::entities::{ScopeType, ShareableType, TargetType};
use domain::value_objects::SystemId;
#[tokio::test]
async fn shares_with_user() {
let share_repo = Arc::new(InMemoryShareRepository::new());
let event_pub = Arc::new(StubEventPublisher::new());
let handler = ShareResourceHandler::new(share_repo, event_pub.clone());
let (scope, target) = handler.execute(ShareResourceCommand {
shareable_type: ShareableType::Album,
shareable_id: SystemId::new(),
target_type: TargetType::User,
target_id: SystemId::new(),
role_id: SystemId::new(),
created_by: SystemId::new(),
}).await.unwrap();
assert_eq!(scope.scope_type, ScopeType::User);
assert_eq!(target.target_type, TargetType::User);
assert_eq!(target.scope_id, scope.scope_id);
let events = event_pub.published().await;
assert_eq!(events.len(), 1);
}
#[tokio::test]
async fn shares_with_group() {
let share_repo = Arc::new(InMemoryShareRepository::new());
let event_pub = Arc::new(StubEventPublisher::new());
let handler = ShareResourceHandler::new(share_repo, event_pub.clone());
let (scope, target) = handler.execute(ShareResourceCommand {
shareable_type: ShareableType::Asset,
shareable_id: SystemId::new(),
target_type: TargetType::Group,
target_id: SystemId::new(),
role_id: SystemId::new(),
created_by: SystemId::new(),
}).await.unwrap();
assert_eq!(scope.scope_type, ScopeType::Group);
assert_eq!(target.target_type, TargetType::Group);
}