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
This commit is contained in:
2026-05-31 05:00:34 +02:00
parent d62d8157a8
commit fa36bb8c0e
43 changed files with 305 additions and 168 deletions

View File

@@ -0,0 +1,28 @@
use std::sync::Arc;
use application::testing::{InMemoryUserRepository, StubPasswordHasher};
use application::identity::{RegisterUserCommand, RegisterUserHandler, GetProfileQuery, GetProfileHandler};
use domain::errors::DomainError;
use domain::value_objects::SystemId;
#[tokio::test]
async fn returns_existing_user() {
let repo = Arc::new(InMemoryUserRepository::new());
let reg = RegisterUserHandler::new(repo.clone(), Arc::new(StubPasswordHasher));
let user = reg.execute(RegisterUserCommand {
username: "alice".into(),
email: "alice@example.com".into(),
password: "password123".into(),
}).await.unwrap();
let handler = GetProfileHandler::new(repo);
let found = handler.execute(GetProfileQuery { user_id: user.id }).await.unwrap();
assert_eq!(found.username, "alice");
}
#[tokio::test]
async fn returns_not_found_for_missing_user() {
let repo = Arc::new(InMemoryUserRepository::new());
let handler = GetProfileHandler::new(repo);
let result = handler.execute(GetProfileQuery { user_id: SystemId::new() }).await;
assert!(matches!(result, Err(DomainError::NotFound(_))));
}

View File

@@ -0,0 +1 @@
mod get_profile;