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).
This commit is contained in:
56
crates/application/tests/integrations/get_queue_test.rs
Normal file
56
crates/application/tests/integrations/get_queue_test.rs
Normal file
@@ -0,0 +1,56 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user