Files
movies-diary/crates/application/tests/diary/get_movie_social_page_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

65 lines
1.5 KiB
Rust

use domain::testing::test_movie_with_year;
use std::sync::Arc;
use uuid::Uuid;
use domain::{
ports::MovieCommand,
testing::{FakeDiaryQuery, InMemoryStore},
};
use application::{
diary::deps::GetMovieSocialPageDeps, diary::get_movie_social_page,
diary::queries::GetMovieSocialPageQuery,
};
#[tokio::test]
async fn fails_when_movie_not_found() {
let deps = GetMovieSocialPageDeps {
movie_query: InMemoryStore::new(),
diary: FakeDiaryQuery::new() as _,
movie_profile: InMemoryStore::new(),
};
let result = get_movie_social_page::execute(
&deps,
GetMovieSocialPageQuery {
movie_id: Uuid::new_v4(),
limit: 10,
offset: 0,
},
)
.await;
assert!(result.is_err());
}
#[tokio::test]
async fn returns_movie_social_page() {
let movies = InMemoryStore::new();
let movie = test_movie_with_year("Social Movie", 2024);
let movie_uuid = movie.id().value();
movies.upsert_movie(&movie).await.unwrap();
let deps = GetMovieSocialPageDeps {
movie_query: Arc::clone(&movies) as _,
diary: FakeDiaryQuery::new() as _,
movie_profile: InMemoryStore::new(),
};
let result = get_movie_social_page::execute(
&deps,
GetMovieSocialPageQuery {
movie_id: movie_uuid,
limit: 10,
offset: 0,
},
)
.await
.unwrap();
assert_eq!(result.movie.title().value(), "Social Movie");
assert_eq!(result.reviews.items.len(), 0);
}