refactor: LOW+MEDIUM cleanups — CQRS DiaryQuery/GoalCommand+GoalQuery,

test-helpers out of production, decompose get_user_profile_html,
dedup secure_flag, remove vestigial social_query, drop
PersistedImportSession, LoginCommand rename, DeleteAccountDeps,
PersonId macro, ReviewSortBy rename, TUI Command for fs::read,
generic PaginatedResponse<T>, noop ports for production fallbacks
This commit is contained in:
2026-07-10 05:29:02 +02:00
parent 5e0dde656c
commit 6a9b4e5c00
52 changed files with 405 additions and 298 deletions

View File

@@ -14,7 +14,8 @@ async fn creates_goal_and_returns_progress() {
let stats = FakeStatsRepository::new();
let events = NoopEventPublisher::new();
let deps = GoalCommandDeps {
goal: Arc::clone(&goals) as _,
goal_command: Arc::clone(&goals) as _,
goal_query: Arc::clone(&goals) as _,
stats: Arc::clone(&stats) as _,
event_publisher: Arc::clone(&events) as _,
};
@@ -43,7 +44,8 @@ async fn creates_goal_with_review_count() {
stats.set_review_count(Uuid::nil(), 2025, 5);
let events = NoopEventPublisher::new();
let deps = GoalCommandDeps {
goal: Arc::clone(&goals) as _,
goal_command: Arc::clone(&goals) as _,
goal_query: Arc::clone(&goals) as _,
stats: Arc::clone(&stats) as _,
event_publisher: Arc::clone(&events) as _,
};
@@ -68,7 +70,8 @@ async fn emits_goal_created_event() {
let b = TestContextBuilder::new();
let events = NoopEventPublisher::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: Arc::clone(&events) as _,
};
@@ -96,7 +99,8 @@ async fn emits_goal_created_event() {
async fn rejects_duplicate_year() {
let b = TestContextBuilder::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};
@@ -125,7 +129,8 @@ async fn rejects_duplicate_year() {
async fn rejects_year_before_2020() {
let b = TestContextBuilder::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};
@@ -146,7 +151,8 @@ async fn rejects_year_before_2020() {
async fn rejects_zero_target() {
let b = TestContextBuilder::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};

View File

@@ -16,7 +16,8 @@ async fn deletes_existing_goal() {
let stats = FakeStatsRepository::new();
let events = NoopEventPublisher::new();
let deps = GoalCommandDeps {
goal: Arc::clone(&goals) as _,
goal_command: Arc::clone(&goals) as _,
goal_query: Arc::clone(&goals) as _,
stats: Arc::clone(&stats) as _,
event_publisher: Arc::clone(&events) as _,
};
@@ -50,7 +51,8 @@ async fn deletes_existing_goal() {
async fn fails_when_not_found() {
let b = TestContextBuilder::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};

View File

@@ -8,12 +8,13 @@ use crate::test_helpers::TestContextBuilder;
async fn returns_goal_when_exists() {
let b = TestContextBuilder::new();
let cmd_deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};
let query_deps = GoalQueryDeps {
goal: b.goal_repo.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
};
@@ -46,7 +47,7 @@ async fn returns_goal_when_exists() {
async fn returns_none_when_missing() {
let b = TestContextBuilder::new();
let query_deps = GoalQueryDeps {
goal: b.goal_repo.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
};
let result = get::execute(

View File

@@ -8,7 +8,7 @@ use crate::test_helpers::TestContextBuilder;
async fn returns_empty_when_no_goals() {
let b = TestContextBuilder::new();
let query_deps = GoalQueryDeps {
goal: b.goal_repo.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
};
let result = list::execute(
@@ -27,12 +27,13 @@ async fn returns_empty_when_no_goals() {
async fn returns_all_goals_for_user() {
let b = TestContextBuilder::new();
let cmd_deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};
let query_deps = GoalQueryDeps {
goal: b.goal_repo.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
};

View File

@@ -11,7 +11,8 @@ use crate::test_helpers::TestContextBuilder;
async fn updates_target_count() {
let b = TestContextBuilder::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};
@@ -45,7 +46,8 @@ async fn updates_target_count() {
async fn fails_when_goal_not_found() {
let b = TestContextBuilder::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};
@@ -66,7 +68,8 @@ async fn fails_when_goal_not_found() {
async fn rejects_zero_target() {
let b = TestContextBuilder::new();
let deps = GoalCommandDeps {
goal: b.goal_repo.clone(),
goal_command: b.goal_command.clone(),
goal_query: b.goal_query.clone(),
stats: b.stats_repo.clone(),
event_publisher: b.event_publisher.clone(),
};