insights-correlations (#22)
Some checks failed
CI / Check / Test (push) Has been cancelled

Reviewed-on: #22
This commit was merged in pull request #22.
This commit is contained in:
2026-10-12 18:56:55 +00:00
parent 4d221e60de
commit e303ae7f08
139 changed files with 2371 additions and 696 deletions

View File

@@ -103,9 +103,6 @@ impl FakeDiaryQuery {
.insert(movie.id().value(), (movie, reviews));
}
/// Configures what `query_diary` returns. Without this, `query_diary` keeps
/// its original always-empty behavior — this is purely opt-in for tests that
/// need to prove entries actually flow through a use case.
pub fn set_diary_page(&self, page: Paginated<DiaryEntry>) {
*self.diary_page.lock().unwrap() = Some(page);
}

View File

@@ -347,9 +347,6 @@ impl WatchlistRepository for InMemoryWatchlistRepository {
// ── InMemoryRemoteWatchlistRepository ─────────────────────────────────────────
/// Unlike `NoopRemoteWatchlistRepository`, this actually stores what it's given —
/// needed by tests that must prove a federated-watchlist read returns real seeded
/// data, not just an empty default that happens to match by coincidence.
pub struct InMemoryRemoteWatchlistRepository {
store: Mutex<Vec<RemoteWatchlistEntry>>,
}
@@ -405,10 +402,6 @@ impl RemoteWatchlistRepository for InMemoryRemoteWatchlistRepository {
Ok(())
}
/// Real adapters derive `uuid` from the actor URL via a SQL-side hash — not
/// domain logic, so this fake doesn't replicate it. It simply returns
/// everything seeded, which is all callers in this workspace need: tests seed
/// exactly the entries for the owner under test.
async fn get_by_derived_uuid(
&self,
_uuid: Uuid,

View File

@@ -0,0 +1,52 @@
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use async_trait::async_trait;
use crate::{
errors::DomainError, models::insights::WatchRow, ports::InsightsQuery, value_objects::UserId,
};
// ── PanicInsightsQuery ──────────────────────────────────────────────────────
pub struct PanicInsightsQuery;
#[async_trait]
impl InsightsQuery for PanicInsightsQuery {
async fn get_watch_rows(&self, _: &UserId) -> Result<Vec<WatchRow>, DomainError> {
panic!("PanicInsightsQuery called")
}
}
// ── InMemoryInsightsQuery ───────────────────────────────────────────────────
pub struct InMemoryInsightsQuery {
pub rows_by_user: Mutex<HashMap<uuid::Uuid, Vec<WatchRow>>>,
}
impl InMemoryInsightsQuery {
pub fn new() -> Arc<Self> {
Arc::new(Self {
rows_by_user: Mutex::new(HashMap::new()),
})
}
pub fn with_rows(user_id: uuid::Uuid, rows: Vec<WatchRow>) -> Arc<Self> {
let query = Self::new();
query.rows_by_user.lock().unwrap().insert(user_id, rows);
query
}
}
#[async_trait]
impl InsightsQuery for InMemoryInsightsQuery {
async fn get_watch_rows(&self, user_id: &UserId) -> Result<Vec<WatchRow>, DomainError> {
Ok(self
.rows_by_user
.lock()
.unwrap()
.get(&user_id.value())
.cloned()
.unwrap_or_default())
}
}

View File

@@ -1,11 +1,13 @@
mod fakes;
mod in_memory;
mod insights;
mod noops;
mod panics;
mod wrapup;
pub use fakes::*;
pub use in_memory::*;
pub use insights::*;
pub use noops::*;
pub use panics::*;
pub use wrapup::*;