feat: atomic goal, watchlist, profile writes

This commit is contained in:
2026-10-26 00:49:28 +01:00
parent c8a1e8bfe4
commit 62ad9f4017
48 changed files with 1296 additions and 264 deletions

View File

@@ -73,10 +73,13 @@ async fn seed_user_with_dependents(store: &Arc<InMemoryStore>) -> (UserId, Movie
store.upsert_movie(&movie).await.unwrap();
store
.add(&WatchlistEntry::new(user_id.clone(), movie.id().clone()))
.add(
&WatchlistEntry::new(user_id.clone(), movie.id().clone()),
&[],
)
.await
.unwrap();
GoalCommand::save(&**store, &test_goal(&user_id, 2024, 50))
GoalCommand::save(&**store, &test_goal(&user_id, 2024, 50), &[])
.await
.unwrap();
UserSettingsRepository::save(&**store, &UserSettings::new(user_id.clone()))
@@ -89,6 +92,7 @@ async fn seed_user_with_dependents(store: &Arc<InMemoryStore>) -> (UserId, Movie
name: "Site".into(),
value: "https://example.com".into(),
}],
&[],
)
.await
.unwrap();
@@ -197,10 +201,10 @@ async fn deleting_a_user_leaves_other_users_rows_alone() {
let bystander = test_user("carol");
UserRepository::save(&*store, &bystander).await.unwrap();
store
.add(&WatchlistEntry::new(
bystander.id().clone(),
movie.id().clone(),
))
.add(
&WatchlistEntry::new(bystander.id().clone(), movie.id().clone()),
&[],
)
.await
.unwrap();
@@ -219,7 +223,10 @@ async fn seed_movie_with_dependents(
let movie = test_movie("Heat");
store.upsert_movie(&movie).await.unwrap();
store
.add(&WatchlistEntry::new(user.id().clone(), movie.id().clone()))
.add(
&WatchlistEntry::new(user.id().clone(), movie.id().clone()),
&[],
)
.await
.unwrap();
store.upsert(&movie_profile(movie.id())).await.unwrap();
@@ -327,11 +334,11 @@ async fn saving_a_user_with_a_taken_email_is_a_validation_error() {
async fn saving_a_second_goal_for_the_same_user_and_year_is_an_infrastructure_error() {
let store = InMemoryStore::new();
let user_id = UserId::generate();
GoalCommand::save(&*store, &test_goal(&user_id, 2024, 10))
GoalCommand::save(&*store, &test_goal(&user_id, 2024, 10), &[])
.await
.unwrap();
let result = GoalCommand::save(&*store, &test_goal(&user_id, 2024, 20)).await;
let result = GoalCommand::save(&*store, &test_goal(&user_id, 2024, 20), &[]).await;
assert!(matches!(result, Err(DomainError::InfrastructureError(_))));
assert_eq!(store.goal_count(), 1);
@@ -344,11 +351,11 @@ async fn adding_the_same_movie_to_a_watchlist_twice_keeps_one_entry() {
let movie_id = MovieId::generate();
store
.add(&WatchlistEntry::new(user_id.clone(), movie_id.clone()))
.add(&WatchlistEntry::new(user_id.clone(), movie_id.clone()), &[])
.await
.unwrap();
store
.add(&WatchlistEntry::new(user_id, movie_id))
.add(&WatchlistEntry::new(user_id, movie_id), &[])
.await
.unwrap();