Files
k-photos/crates/application/tests/organization/commands/create_album.rs
Gabriel Kaszewski fa36bb8c0e refactor: restructure application to CQRS, update api-types + presentation
- application: replace flat use_cases/ with identity/{commands,queries}/ and organization/commands/
- each use case now split into Command/Query struct + Handler struct
- api-types: add username to RegisterRequest/UserResponse, add CreateAlbumRequest/AlbumResponse
- presentation: update state, handlers, factory to use new handler types
- tests: restructured to match CQRS module layout, added get_profile tests
2026-05-31 05:00:34 +02:00

31 lines
1.0 KiB
Rust

use std::sync::Arc;
use application::testing::InMemoryAlbumRepository;
use application::organization::{CreateAlbumCommand, CreateAlbumHandler};
use domain::errors::DomainError;
use domain::value_objects::SystemId;
#[tokio::test]
async fn creates_album() {
let repo = Arc::new(InMemoryAlbumRepository::new());
let handler = CreateAlbumHandler::new(repo);
let creator = SystemId::new();
let album = handler.execute(CreateAlbumCommand {
title: "Vacation 2024".into(),
creator_id: creator,
}).await.unwrap();
assert_eq!(album.title, "Vacation 2024");
assert_eq!(album.creator_user_id, creator);
assert_eq!(album.asset_count(), 0);
}
#[tokio::test]
async fn rejects_empty_title() {
let repo = Arc::new(InMemoryAlbumRepository::new());
let handler = CreateAlbumHandler::new(repo);
let result = handler.execute(CreateAlbumCommand {
title: "".into(),
creator_id: SystemId::new(),
}).await;
assert!(matches!(result, Err(DomainError::Validation(_))));
}