app: add organization + sharing commands/queries
This commit is contained in:
38
crates/application/tests/organization/queries/get_album.rs
Normal file
38
crates/application/tests/organization/queries/get_album.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use std::sync::Arc;
|
||||
use application::testing::InMemoryAlbumRepository;
|
||||
use application::organization::{
|
||||
CreateAlbumCommand, CreateAlbumHandler,
|
||||
GetAlbumQuery, GetAlbumHandler,
|
||||
};
|
||||
use domain::errors::DomainError;
|
||||
use domain::value_objects::SystemId;
|
||||
|
||||
#[tokio::test]
|
||||
async fn returns_album() {
|
||||
let repo = Arc::new(InMemoryAlbumRepository::new());
|
||||
let creator = SystemId::new();
|
||||
|
||||
let create_handler = CreateAlbumHandler::new(repo.clone());
|
||||
let album = create_handler.execute(CreateAlbumCommand {
|
||||
title: "My Album".into(),
|
||||
creator_id: creator,
|
||||
}).await.unwrap();
|
||||
|
||||
let query_handler = GetAlbumHandler::new(repo);
|
||||
let found = query_handler.execute(GetAlbumQuery {
|
||||
album_id: album.album_id,
|
||||
}).await.unwrap();
|
||||
|
||||
assert_eq!(found.album_id, album.album_id);
|
||||
assert_eq!(found.title, "My Album");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn rejects_nonexistent() {
|
||||
let repo = Arc::new(InMemoryAlbumRepository::new());
|
||||
let handler = GetAlbumHandler::new(repo);
|
||||
let result = handler.execute(GetAlbumQuery {
|
||||
album_id: SystemId::new(),
|
||||
}).await;
|
||||
assert!(matches!(result, Err(DomainError::NotFound(_))));
|
||||
}
|
||||
1
crates/application/tests/organization/queries/mod.rs
Normal file
1
crates/application/tests/organization/queries/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod get_album;
|
||||
Reference in New Issue
Block a user