Files
movies-diary/crates/application/tests/integrations/get_queue_test.rs
Gabriel Kaszewski 8526b77f18 test: move application tests to tests/
test_support/test_helpers -> tests/support; watched_at unified w/ domain test_watched_at (2024-03-15).
Kept inline: users::diary_filter tests (feed_sort_to_direction_all_variants, paged_user_filter_builds_correctly) - pub(super) helpers in private module.
Dropped stale never-compiled users/tests/get_users.rs (old execute signature).
2026-10-25 22:36:52 +01:00

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);
}