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:
58
crates/application/tests/watchlist/is_on_test.rs
Normal file
58
crates/application/tests/watchlist/is_on_test.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::models::WatchlistEntry;
|
||||
use domain::ports::WatchlistRepository;
|
||||
use domain::testing::InMemoryStore;
|
||||
use domain::value_objects::{MovieId, UserId};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::support::TestContextBuilder;
|
||||
use application::watchlist::{deps::IsOnWatchlistDeps, is_on, queries::IsOnWatchlistQuery};
|
||||
|
||||
#[tokio::test]
|
||||
async fn returns_true_when_present() {
|
||||
let watchlist = InMemoryStore::new();
|
||||
let uid = Uuid::new_v4();
|
||||
let mid = Uuid::new_v4();
|
||||
watchlist
|
||||
.add(&WatchlistEntry::new(
|
||||
UserId::from_uuid(uid),
|
||||
MovieId::from_uuid(mid),
|
||||
))
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let deps = IsOnWatchlistDeps {
|
||||
watchlist: Arc::clone(&watchlist) as _,
|
||||
};
|
||||
let result = is_on::execute(
|
||||
&deps,
|
||||
IsOnWatchlistQuery {
|
||||
user_id: uid,
|
||||
movie_id: mid,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(result);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn returns_false_when_absent() {
|
||||
let b = TestContextBuilder::new();
|
||||
let deps = IsOnWatchlistDeps {
|
||||
watchlist: b.watchlist_repo.clone(),
|
||||
};
|
||||
let result = is_on::execute(
|
||||
&deps,
|
||||
IsOnWatchlistQuery {
|
||||
user_id: Uuid::new_v4(),
|
||||
movie_id: Uuid::new_v4(),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(!result);
|
||||
}
|
||||
Reference in New Issue
Block a user