refactor: remaining MEDIUM — CQRS splits, DI Deps, profile dedup, event Value, response enum
M1: MovieRepository→MovieCommand/MovieQuery, WatchEventRepository→ WatchEventCommand/WatchEventQuery M2: goals/ and import/ use Deps structs M7: extract upload_image helper in update_profile M8: FederationDeliveryRequested activity_json String→serde_json::Value M11: UserProfileResponse uses ProfileViewData enum
This commit is contained in:
@@ -3,6 +3,7 @@ use std::sync::Arc;
|
||||
use domain::testing::{FakeStatsRepository, InMemoryGoalRepository, NoopEventPublisher};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::goals::deps::GoalCommandDeps;
|
||||
use crate::goals::{
|
||||
commands::{CreateGoalCommand, DeleteGoalCommand},
|
||||
create, delete,
|
||||
@@ -14,11 +15,14 @@ async fn deletes_existing_goal() {
|
||||
let goals = InMemoryGoalRepository::new();
|
||||
let stats = FakeStatsRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = GoalCommandDeps {
|
||||
goal: Arc::clone(&goals) as _,
|
||||
stats: Arc::clone(&stats) as _,
|
||||
event_publisher: Arc::clone(&events) as _,
|
||||
};
|
||||
|
||||
create::execute(
|
||||
Arc::clone(&goals) as _,
|
||||
Arc::clone(&stats) as _,
|
||||
Arc::clone(&events) as _,
|
||||
&deps,
|
||||
CreateGoalCommand {
|
||||
user_id: Uuid::nil(),
|
||||
year: 2025,
|
||||
@@ -30,8 +34,7 @@ async fn deletes_existing_goal() {
|
||||
assert_eq!(goals.count(), 1);
|
||||
|
||||
delete::execute(
|
||||
Arc::clone(&goals) as _,
|
||||
Arc::clone(&events) as _,
|
||||
&deps,
|
||||
DeleteGoalCommand {
|
||||
user_id: Uuid::nil(),
|
||||
year: 2025,
|
||||
@@ -46,9 +49,13 @@ async fn deletes_existing_goal() {
|
||||
#[tokio::test]
|
||||
async fn fails_when_not_found() {
|
||||
let b = TestContextBuilder::new();
|
||||
let deps = GoalCommandDeps {
|
||||
goal: b.goal_repo.clone(),
|
||||
stats: b.stats_repo.clone(),
|
||||
event_publisher: b.event_publisher.clone(),
|
||||
};
|
||||
let result = delete::execute(
|
||||
b.goal_repo.clone(),
|
||||
b.event_publisher.clone(),
|
||||
&deps,
|
||||
DeleteGoalCommand {
|
||||
user_id: Uuid::nil(),
|
||||
year: 2025,
|
||||
|
||||
Reference in New Issue
Block a user