Ride writes: WrapUpRequested/Completed (wrapup create/set_complete), MovieDiscovered (resolve upsert, new+ext id only), PosterSynced (poster handler upsert), MovieDeleted (delete_movie), WatchEventIngested (save). Deps drop event_publisher: wrapup, ingest, delete_review, watchlist add, review logger. Remaining .publish( sites: announce-only: users/delete_account UserDeleted, person/get + get_credits PersonEnrichmentRequested, jobs/enrichment_staleness, http-axum search, movies/sync_poster + poster_sync_handler + image-converter backfill + users/update_profile ImageStored (object storage), activitypub federation_event_bridge (reacting to events). rides write, deferred: social/execute (see report), activitypub review_handler MovieEnrichmentRequested (after save_remote_review).
57 lines
1.3 KiB
Rust
57 lines
1.3 KiB
Rust
use std::sync::Arc;
|
|
|
|
use chrono::Utc;
|
|
use domain::models::{WatchEvent, WatchEventSource};
|
|
use domain::ports::WatchEventCommand;
|
|
use domain::testing::InMemoryStore;
|
|
use domain::value_objects::UserId;
|
|
use uuid::Uuid;
|
|
|
|
use application::integrations::deps::GetWatchQueueDeps;
|
|
use application::integrations::{get_queue, queries::GetWatchQueueQuery};
|
|
|
|
fn deps(events: &Arc<InMemoryStore>) -> GetWatchQueueDeps {
|
|
GetWatchQueueDeps {
|
|
watch_event_query: Arc::clone(events) as _,
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn returns_empty_when_no_events() {
|
|
let events = InMemoryStore::new();
|
|
|
|
let result = get_queue::execute(
|
|
&deps(&events),
|
|
GetWatchQueueQuery {
|
|
user_id: Uuid::new_v4(),
|
|
},
|
|
)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert!(result.is_empty());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn returns_pending_events() {
|
|
let events = InMemoryStore::new();
|
|
|
|
let user_id = Uuid::new_v4();
|
|
let event = WatchEvent::new(
|
|
UserId::from_uuid(user_id),
|
|
"Blade Runner 2049".into(),
|
|
Some(2017),
|
|
None,
|
|
WatchEventSource::Jellyfin,
|
|
Utc::now().naive_utc(),
|
|
None,
|
|
);
|
|
events.save(&event, &[]).await.unwrap();
|
|
|
|
let result = get_queue::execute(&deps(&events), GetWatchQueueQuery { user_id })
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(result.len(), 1);
|
|
}
|