diff --git a/crates/application/src/auth/login.rs b/crates/application/src/auth/login.rs index 3c25cfc0..a47adf29 100644 --- a/crates/application/src/auth/login.rs +++ b/crates/application/src/auth/login.rs @@ -52,7 +52,3 @@ pub async fn execute(deps: &LoginDeps, query: LoginCommand) -> Result Result<(), DomainError> { deps.refresh_session.revoke(refresh_token).await } - -#[cfg(test)] -#[path = "tests/logout.rs"] -mod tests; diff --git a/crates/application/src/auth/refresh.rs b/crates/application/src/auth/refresh.rs index ec354e76..15e6d8c8 100644 --- a/crates/application/src/auth/refresh.rs +++ b/crates/application/src/auth/refresh.rs @@ -50,7 +50,3 @@ pub async fn execute( expires_at: generated.expires_at, }) } - -#[cfg(test)] -#[path = "tests/refresh.rs"] -mod tests; diff --git a/crates/application/src/auth/register.rs b/crates/application/src/auth/register.rs index 2d398d7f..b19ae607 100644 --- a/crates/application/src/auth/register.rs +++ b/crates/application/src/auth/register.rs @@ -32,7 +32,3 @@ pub async fn execute(deps: &RegisterDeps, cmd: RegisterCommand) -> Result<(), Do .save(&User::new(email, username, hash, cmd.role)) .await } - -#[cfg(test)] -#[path = "tests/register.rs"] -mod tests; diff --git a/crates/application/src/auth/register_and_login.rs b/crates/application/src/auth/register_and_login.rs index 5a1c90a0..4f11939d 100644 --- a/crates/application/src/auth/register_and_login.rs +++ b/crates/application/src/auth/register_and_login.rs @@ -44,7 +44,3 @@ pub async fn execute( ) .await } - -#[cfg(test)] -#[path = "tests/register_and_login.rs"] -mod tests; diff --git a/crates/application/src/diary/delete_review.rs b/crates/application/src/diary/delete_review.rs index 0b804236..5c6c7000 100644 --- a/crates/application/src/diary/delete_review.rs +++ b/crates/application/src/diary/delete_review.rs @@ -52,7 +52,3 @@ pub async fn execute(deps: &DeleteReviewDeps, cmd: DeleteReviewCommand) -> Resul Ok(()) } - -#[cfg(test)] -#[path = "tests/delete_review.rs"] -mod tests; diff --git a/crates/application/src/diary/edit_review.rs b/crates/application/src/diary/edit_review.rs index c1d21770..64f1c159 100644 --- a/crates/application/src/diary/edit_review.rs +++ b/crates/application/src/diary/edit_review.rs @@ -55,7 +55,3 @@ pub async fn execute(deps: &EditReviewDeps, cmd: EditReviewCommand) -> Result<() Ok(()) } - -#[cfg(test)] -#[path = "tests/edit_review.rs"] -mod tests; diff --git a/crates/application/src/diary/get_activity_feed.rs b/crates/application/src/diary/get_activity_feed.rs index 6f5efe44..ca761f5f 100644 --- a/crates/application/src/diary/get_activity_feed.rs +++ b/crates/application/src/diary/get_activity_feed.rs @@ -60,7 +60,3 @@ async fn build_following_filter( remote_actor_urls: remote_urls, }) } - -#[cfg(test)] -#[path = "tests/get_activity_feed.rs"] -mod tests; diff --git a/crates/application/src/diary/get_diary.rs b/crates/application/src/diary/get_diary.rs index dae085ca..6582e5d0 100644 --- a/crates/application/src/diary/get_diary.rs +++ b/crates/application/src/diary/get_diary.rs @@ -29,7 +29,3 @@ pub async fn execute( deps.diary.query_diary(&filter).await } - -#[cfg(test)] -#[path = "tests/get_diary.rs"] -mod tests; diff --git a/crates/application/src/diary/get_movie_social_page.rs b/crates/application/src/diary/get_movie_social_page.rs index 62d5e21e..ac7f5fdb 100644 --- a/crates/application/src/diary/get_movie_social_page.rs +++ b/crates/application/src/diary/get_movie_social_page.rs @@ -42,7 +42,3 @@ pub async fn execute( profile, }) } - -#[cfg(test)] -#[path = "tests/get_movie_social_page.rs"] -mod tests; diff --git a/crates/application/src/diary/get_review_history.rs b/crates/application/src/diary/get_review_history.rs index a8f4d3e3..53aad064 100644 --- a/crates/application/src/diary/get_review_history.rs +++ b/crates/application/src/diary/get_review_history.rs @@ -22,7 +22,3 @@ pub async fn execute( Ok((history, trend)) } - -#[cfg(test)] -#[path = "tests/get_review_history.rs"] -mod tests; diff --git a/crates/application/src/diary/get_user_feed.rs b/crates/application/src/diary/get_user_feed.rs index 00ff5467..4a424690 100644 --- a/crates/application/src/diary/get_user_feed.rs +++ b/crates/application/src/diary/get_user_feed.rs @@ -52,7 +52,3 @@ pub async fn execute( entries: page.items, }) } - -#[cfg(test)] -#[path = "tests/get_user_feed.rs"] -mod tests; diff --git a/crates/application/src/diary/log_review.rs b/crates/application/src/diary/log_review.rs index ab965add..ae1255f2 100644 --- a/crates/application/src/diary/log_review.rs +++ b/crates/application/src/diary/log_review.rs @@ -10,7 +10,3 @@ pub async fn execute( ) -> Result<(), DomainError> { review_logger.log_review(cmd).await } - -#[cfg(test)] -#[path = "tests/log_review.rs"] -mod tests; diff --git a/crates/application/src/diary/movie_resolver.rs b/crates/application/src/diary/movie_resolver.rs index 221c7b8b..25ac9697 100644 --- a/crates/application/src/diary/movie_resolver.rs +++ b/crates/application/src/diary/movie_resolver.rs @@ -179,7 +179,3 @@ impl ResolutionStrategy for ManualMovieStrategy { } } } - -#[cfg(test)] -#[path = "tests/movie_resolver.rs"] -mod tests; diff --git a/crates/application/src/diary/review_logger.rs b/crates/application/src/diary/review_logger.rs index 7472b924..a5e4683f 100644 --- a/crates/application/src/diary/review_logger.rs +++ b/crates/application/src/diary/review_logger.rs @@ -110,7 +110,3 @@ impl ReviewLogger for DefaultReviewLogger { self.event_publisher.publish(&review_event).await } } - -#[cfg(test)] -#[path = "tests/review_logger.rs"] -mod tests; diff --git a/crates/application/src/goals/create.rs b/crates/application/src/goals/create.rs index e3c6f677..4ada4d4d 100644 --- a/crates/application/src/goals/create.rs +++ b/crates/application/src/goals/create.rs @@ -47,7 +47,3 @@ pub async fn execute( current_count, }) } - -#[cfg(test)] -#[path = "tests/create.rs"] -mod tests; diff --git a/crates/application/src/goals/delete.rs b/crates/application/src/goals/delete.rs index ab25278d..ce092a77 100644 --- a/crates/application/src/goals/delete.rs +++ b/crates/application/src/goals/delete.rs @@ -23,7 +23,3 @@ pub async fn execute(deps: &GoalCommandDeps, cmd: DeleteGoalCommand) -> Result<( Ok(()) } - -#[cfg(test)] -#[path = "tests/delete.rs"] -mod tests; diff --git a/crates/application/src/goals/get.rs b/crates/application/src/goals/get.rs index 6e8db792..0fa4e5dd 100644 --- a/crates/application/src/goals/get.rs +++ b/crates/application/src/goals/get.rs @@ -25,7 +25,3 @@ pub async fn execute( current_count, })) } - -#[cfg(test)] -#[path = "tests/get.rs"] -mod tests; diff --git a/crates/application/src/goals/list.rs b/crates/application/src/goals/list.rs index 10cbeac5..939e5ed8 100644 --- a/crates/application/src/goals/list.rs +++ b/crates/application/src/goals/list.rs @@ -20,7 +20,3 @@ pub async fn execute( Ok(result) } - -#[cfg(test)] -#[path = "tests/list.rs"] -mod tests; diff --git a/crates/application/src/goals/update.rs b/crates/application/src/goals/update.rs index f91db407..d0fbe230 100644 --- a/crates/application/src/goals/update.rs +++ b/crates/application/src/goals/update.rs @@ -35,7 +35,3 @@ pub async fn execute( current_count, }) } - -#[cfg(test)] -#[path = "tests/update.rs"] -mod tests; diff --git a/crates/application/src/import/apply_mapping.rs b/crates/application/src/import/apply_mapping.rs index a9b32615..2ef944d8 100644 --- a/crates/application/src/import/apply_mapping.rs +++ b/crates/application/src/import/apply_mapping.rs @@ -87,7 +87,3 @@ async fn mark_duplicates( Ok(()) } - -#[cfg(test)] -#[path = "tests/apply_mapping.rs"] -mod tests; diff --git a/crates/application/src/import/apply_profile.rs b/crates/application/src/import/apply_profile.rs index d1330d96..9b719668 100644 --- a/crates/application/src/import/apply_profile.rs +++ b/crates/application/src/import/apply_profile.rs @@ -27,7 +27,3 @@ pub async fn execute( session.row_results = None; deps.import_session.update(&session).await } - -#[cfg(test)] -#[path = "tests/apply_profile.rs"] -mod tests; diff --git a/crates/application/src/import/apply_profile_and_map.rs b/crates/application/src/import/apply_profile_and_map.rs index ad214ef0..09ec468f 100644 --- a/crates/application/src/import/apply_profile_and_map.rs +++ b/crates/application/src/import/apply_profile_and_map.rs @@ -58,7 +58,3 @@ pub async fn execute( ) .await } - -#[cfg(test)] -#[path = "tests/apply_profile_and_map.rs"] -mod tests; diff --git a/crates/application/src/import/cleanup.rs b/crates/application/src/import/cleanup.rs index 2bd6416d..df9a0bc0 100644 --- a/crates/application/src/import/cleanup.rs +++ b/crates/application/src/import/cleanup.rs @@ -5,7 +5,3 @@ use domain::{errors::DomainError, ports::ImportSessionRepository}; pub async fn execute(import_session: Arc) -> Result { import_session.delete_expired().await } - -#[cfg(test)] -#[path = "tests/cleanup.rs"] -mod tests; diff --git a/crates/application/src/import/create_session.rs b/crates/application/src/import/create_session.rs index cc22281a..f3aef72a 100644 --- a/crates/application/src/import/create_session.rs +++ b/crates/application/src/import/create_session.rs @@ -41,7 +41,3 @@ pub async fn execute( sample_rows, }) } - -#[cfg(test)] -#[path = "tests/create_session.rs"] -mod tests; diff --git a/crates/application/src/import/delete_profile.rs b/crates/application/src/import/delete_profile.rs index 69e9fcb0..f8ae207b 100644 --- a/crates/application/src/import/delete_profile.rs +++ b/crates/application/src/import/delete_profile.rs @@ -18,7 +18,3 @@ pub async fn execute( .ok_or_else(|| DomainError::NotFound("import profile".into()))?; deps.import_profile.delete(&profile_id).await } - -#[cfg(test)] -#[path = "tests/delete_profile.rs"] -mod tests; diff --git a/crates/application/src/import/execute.rs b/crates/application/src/import/execute.rs index 73df7b7a..808e3276 100644 --- a/crates/application/src/import/execute.rs +++ b/crates/application/src/import/execute.rs @@ -88,10 +88,6 @@ pub async fn execute( }) } -#[cfg(test)] -#[path = "tests/execute.rs"] -mod tests; - /// Row-level validation failures keep their bare message in the summary. fn import_error_message(e: DomainError) -> String { match e { diff --git a/crates/application/src/import/get_mapping_stage.rs b/crates/application/src/import/get_mapping_stage.rs index 583fa107..67b1b15a 100644 --- a/crates/application/src/import/get_mapping_stage.rs +++ b/crates/application/src/import/get_mapping_stage.rs @@ -33,7 +33,3 @@ pub async fn execute( sample_rows, }) } - -#[cfg(test)] -#[path = "tests/get_mapping_stage.rs"] -mod tests; diff --git a/crates/application/src/import/get_preview_stage.rs b/crates/application/src/import/get_preview_stage.rs index f9e6aaf5..56886a54 100644 --- a/crates/application/src/import/get_preview_stage.rs +++ b/crates/application/src/import/get_preview_stage.rs @@ -37,7 +37,3 @@ pub async fn execute( Ok(PreviewStage::Ready(PreviewRows { columns, rows })) } - -#[cfg(test)] -#[path = "tests/get_preview_stage.rs"] -mod tests; diff --git a/crates/application/src/import/get_session_state.rs b/crates/application/src/import/get_session_state.rs index 4898ad3c..241d35d8 100644 --- a/crates/application/src/import/get_session_state.rs +++ b/crates/application/src/import/get_session_state.rs @@ -37,7 +37,3 @@ pub async fn execute( row_count, }) } - -#[cfg(test)] -#[path = "tests/get_session_state.rs"] -mod tests; diff --git a/crates/application/src/import/list_profiles.rs b/crates/application/src/import/list_profiles.rs index ca5e214d..ba731597 100644 --- a/crates/application/src/import/list_profiles.rs +++ b/crates/application/src/import/list_profiles.rs @@ -7,7 +7,3 @@ pub async fn execute( ) -> Result, DomainError> { deps.import_profile.list_for_user(user_id).await } - -#[cfg(test)] -#[path = "tests/list_profiles.rs"] -mod tests; diff --git a/crates/application/src/import/save_profile.rs b/crates/application/src/import/save_profile.rs index cfc4273d..5b9d8d49 100644 --- a/crates/application/src/import/save_profile.rs +++ b/crates/application/src/import/save_profile.rs @@ -33,7 +33,3 @@ pub async fn execute( deps.import_profile.save(&profile).await?; Ok(id) } - -#[cfg(test)] -#[path = "tests/save_profile.rs"] -mod tests; diff --git a/crates/application/src/insights/get.rs b/crates/application/src/insights/get.rs index ae610a9a..3f907bd2 100644 --- a/crates/application/src/insights/get.rs +++ b/crates/application/src/insights/get.rs @@ -18,7 +18,3 @@ pub async fn execute( &rows, tz, )) } - -#[cfg(test)] -#[path = "tests/get.rs"] -mod tests; diff --git a/crates/application/src/integrations/cleanup.rs b/crates/application/src/integrations/cleanup.rs index 02d7fc80..3492ff42 100644 --- a/crates/application/src/integrations/cleanup.rs +++ b/crates/application/src/integrations/cleanup.rs @@ -9,7 +9,3 @@ pub async fn execute(watch_event_command: Arc) -> Result< .delete_non_pending_older_than(cutoff) .await } - -#[cfg(test)] -#[path = "tests/cleanup.rs"] -mod tests; diff --git a/crates/application/src/integrations/confirm.rs b/crates/application/src/integrations/confirm.rs index 027a6108..6bf6209e 100644 --- a/crates/application/src/integrations/confirm.rs +++ b/crates/application/src/integrations/confirm.rs @@ -67,7 +67,3 @@ pub async fn execute( Ok(confirmed) } - -#[cfg(test)] -#[path = "tests/confirm.rs"] -mod tests; diff --git a/crates/application/src/integrations/dismiss.rs b/crates/application/src/integrations/dismiss.rs index cc90721e..12246c6e 100644 --- a/crates/application/src/integrations/dismiss.rs +++ b/crates/application/src/integrations/dismiss.rs @@ -41,7 +41,3 @@ pub async fn execute( Ok(count as u32) } - -#[cfg(test)] -#[path = "tests/dismiss.rs"] -mod tests; diff --git a/crates/application/src/integrations/generate_token.rs b/crates/application/src/integrations/generate_token.rs index aeee1424..7fe845a0 100644 --- a/crates/application/src/integrations/generate_token.rs +++ b/crates/application/src/integrations/generate_token.rs @@ -36,7 +36,3 @@ pub fn hash_token(plaintext: &str) -> String { hasher.update(plaintext.as_bytes()); hex::encode(hasher.finalize()) } - -#[cfg(test)] -#[path = "tests/generate_token.rs"] -mod tests; diff --git a/crates/application/src/integrations/get_queue.rs b/crates/application/src/integrations/get_queue.rs index 1516ed2c..13529eb6 100644 --- a/crates/application/src/integrations/get_queue.rs +++ b/crates/application/src/integrations/get_queue.rs @@ -9,7 +9,3 @@ pub async fn execute( let user_id = UserId::from_uuid(query.user_id); deps.watch_event_query.list_pending(&user_id).await } - -#[cfg(test)] -#[path = "tests/get_queue.rs"] -mod tests; diff --git a/crates/application/src/integrations/get_tokens.rs b/crates/application/src/integrations/get_tokens.rs index 66faf731..8be2a708 100644 --- a/crates/application/src/integrations/get_tokens.rs +++ b/crates/application/src/integrations/get_tokens.rs @@ -9,7 +9,3 @@ pub async fn execute( let user_id = UserId::from_uuid(query.user_id); deps.webhook_token.list_by_user(&user_id).await } - -#[cfg(test)] -#[path = "tests/get_tokens.rs"] -mod tests; diff --git a/crates/application/src/integrations/ingest.rs b/crates/application/src/integrations/ingest.rs index 384baa2c..d7fe4da7 100644 --- a/crates/application/src/integrations/ingest.rs +++ b/crates/application/src/integrations/ingest.rs @@ -62,7 +62,3 @@ pub async fn execute( Ok(()) } - -#[cfg(test)] -#[path = "tests/ingest.rs"] -mod tests; diff --git a/crates/application/src/integrations/revoke_token.rs b/crates/application/src/integrations/revoke_token.rs index 8122cc23..a33ba179 100644 --- a/crates/application/src/integrations/revoke_token.rs +++ b/crates/application/src/integrations/revoke_token.rs @@ -13,7 +13,3 @@ pub async fn execute( let token_id = WebhookTokenId::from_uuid(cmd.token_id); deps.webhook_token.delete(&token_id, &user_id).await } - -#[cfg(test)] -#[path = "tests/revoke_token.rs"] -mod tests; diff --git a/crates/application/src/lib.rs b/crates/application/src/lib.rs index d47b1b82..e3eaeca3 100644 --- a/crates/application/src/lib.rs +++ b/crates/application/src/lib.rs @@ -19,16 +19,6 @@ pub mod users; pub mod watchlist; pub mod wrapup; -#[cfg(test)] -pub mod test_helpers; - -#[cfg(test)] -mod test_support; - -#[cfg(test)] -#[path = "tests/services.rs"] -mod services_tests; - pub use deps::Deps; pub use deps::{WorkerDeps, WorkerServices}; pub use movies::MovieDiscoveryIndexer; diff --git a/crates/application/src/movies/enrich_movie.rs b/crates/application/src/movies/enrich_movie.rs index f95d728c..32f9f838 100644 --- a/crates/application/src/movies/enrich_movie.rs +++ b/crates/application/src/movies/enrich_movie.rs @@ -76,7 +76,3 @@ fn extract_persons(cast: &[CastMember], crew: &[CrewMember]) -> Vec { seen.into_values().collect() } - -#[cfg(test)] -#[path = "tests/enrich_movie.rs"] -mod tests; diff --git a/crates/application/src/movies/get_movie_profile.rs b/crates/application/src/movies/get_movie_profile.rs index 03335e6e..089f693b 100644 --- a/crates/application/src/movies/get_movie_profile.rs +++ b/crates/application/src/movies/get_movie_profile.rs @@ -76,7 +76,3 @@ pub async fn execute( } })) } - -#[cfg(test)] -#[path = "tests/get_movie_profile.rs"] -mod tests; diff --git a/crates/application/src/movies/get_movies.rs b/crates/application/src/movies/get_movies.rs index f4fd975f..cc68de9e 100644 --- a/crates/application/src/movies/get_movies.rs +++ b/crates/application/src/movies/get_movies.rs @@ -19,7 +19,3 @@ pub async fn execute( }; deps.movie.list_movies(&page, &filter).await } - -#[cfg(test)] -#[path = "tests/get_movies.rs"] -mod tests; diff --git a/crates/application/src/movies/request_enrichment.rs b/crates/application/src/movies/request_enrichment.rs index bb25d69e..95faf7b8 100644 --- a/crates/application/src/movies/request_enrichment.rs +++ b/crates/application/src/movies/request_enrichment.rs @@ -42,7 +42,3 @@ pub async fn fetch_if_stale( Err(e) => Err(e), } } - -#[cfg(test)] -#[path = "tests/request_enrichment.rs"] -mod tests; diff --git a/crates/application/src/movies/sync_poster.rs b/crates/application/src/movies/sync_poster.rs index 99a75a47..a778f513 100644 --- a/crates/application/src/movies/sync_poster.rs +++ b/crates/application/src/movies/sync_poster.rs @@ -83,7 +83,3 @@ pub async fn execute(deps: &SyncPosterDeps, cmd: SyncPosterCommand) -> Result<() Ok(()) } - -#[cfg(test)] -#[path = "tests/sync_poster.rs"] -mod tests; diff --git a/crates/application/src/person/get.rs b/crates/application/src/person/get.rs index 96267203..3405baa4 100644 --- a/crates/application/src/person/get.rs +++ b/crates/application/src/person/get.rs @@ -21,7 +21,3 @@ pub async fn execute(deps: &GetPersonDeps, id: PersonId) -> Result Result Result { deps.search_port.search(&query).await } - -#[cfg(test)] -#[path = "tests/execute.rs"] -mod tests; diff --git a/crates/application/src/social/execute.rs b/crates/application/src/social/execute.rs index b5d97f39..6b928f0a 100644 --- a/crates/application/src/social/execute.rs +++ b/crates/application/src/social/execute.rs @@ -60,7 +60,3 @@ pub async fn execute_command(deps: &SocialCommandDeps, cmd: SocialCmd) -> Result }; deps.event_publisher.publish(&event).await } - -#[cfg(test)] -#[path = "tests/execute.rs"] -mod tests; diff --git a/crates/application/src/social/local_service.rs b/crates/application/src/social/local_service.rs index 368e0ffd..599362b4 100644 --- a/crates/application/src/social/local_service.rs +++ b/crates/application/src/social/local_service.rs @@ -263,7 +263,3 @@ impl ResolvedFollow for LocalSocialService { Ok(()) } } - -#[cfg(test)] -#[path = "tests/local_service.rs"] -mod tests; diff --git a/crates/application/src/users/authorize_admin.rs b/crates/application/src/users/authorize_admin.rs index bec7f06f..1a7e7765 100644 --- a/crates/application/src/users/authorize_admin.rs +++ b/crates/application/src/users/authorize_admin.rs @@ -13,7 +13,3 @@ pub async fn execute( let found = deps.user.find_by_id(&id).await?; Ok(found.map(|user| matches!(user.role(), UserRole::Admin))) } - -#[cfg(test)] -#[path = "tests/authorize_admin.rs"] -mod tests; diff --git a/crates/application/src/users/diary_filter.rs b/crates/application/src/users/diary_filter.rs index e52744e8..326b9cf2 100644 --- a/crates/application/src/users/diary_filter.rs +++ b/crates/application/src/users/diary_filter.rs @@ -38,5 +38,43 @@ pub(super) fn paged_user_filter( } #[cfg(test)] -#[path = "tests/diary_filter.rs"] -mod tests; +mod tests { + use super::*; + + #[test] + fn feed_sort_to_direction_all_variants() { + assert!(matches!( + feed_sort_to_direction(FeedSortBy::Date), + ReviewSortBy::Descending + )); + assert!(matches!( + feed_sort_to_direction(FeedSortBy::DateAsc), + ReviewSortBy::Ascending + )); + assert!(matches!( + feed_sort_to_direction(FeedSortBy::Rating), + ReviewSortBy::ByRatingDesc + )); + assert!(matches!( + feed_sort_to_direction(FeedSortBy::RatingAsc), + ReviewSortBy::ByRatingAsc + )); + } + + #[test] + fn paged_user_filter_builds_correctly() { + let uid = UserId::from_uuid(uuid::Uuid::new_v4()); + let filter = paged_user_filter( + uid.clone(), + ReviewSortBy::Descending, + Some(20), + Some(5), + Some("blade".into()), + false, + ) + .unwrap(); + + assert_eq!(filter.user_id.unwrap().value(), uid.value()); + assert_eq!(filter.search.as_deref(), Some("blade")); + } +} diff --git a/crates/application/src/users/get_current_profile.rs b/crates/application/src/users/get_current_profile.rs index 3a0593e0..4e460fd5 100644 --- a/crates/application/src/users/get_current_profile.rs +++ b/crates/application/src/users/get_current_profile.rs @@ -50,7 +50,3 @@ pub async fn execute( role: found.role().clone(), }) } - -#[cfg(test)] -#[path = "tests/get_current_profile.rs"] -mod tests; diff --git a/crates/application/src/users/get_federated_profile.rs b/crates/application/src/users/get_federated_profile.rs index 0b3198d7..ba16c3bf 100644 --- a/crates/application/src/users/get_federated_profile.rs +++ b/crates/application/src/users/get_federated_profile.rs @@ -13,7 +13,3 @@ pub async fn execute( None => Ok(None), } } - -#[cfg(test)] -#[path = "tests/get_federated_profile.rs"] -mod tests; diff --git a/crates/application/src/users/get_federated_profile_stats.rs b/crates/application/src/users/get_federated_profile_stats.rs index e37b7ff7..913c927e 100644 --- a/crates/application/src/users/get_federated_profile_stats.rs +++ b/crates/application/src/users/get_federated_profile_stats.rs @@ -83,7 +83,3 @@ pub async fn execute( } } } - -#[cfg(test)] -#[path = "tests/get_federated_profile_stats.rs"] -mod tests; diff --git a/crates/application/src/users/get_local_profile.rs b/crates/application/src/users/get_local_profile.rs index fbdc8b30..27687352 100644 --- a/crates/application/src/users/get_local_profile.rs +++ b/crates/application/src/users/get_local_profile.rs @@ -144,7 +144,3 @@ async fn load_social_counts( .collect(); (following, followers, pending) } - -#[cfg(test)] -#[path = "tests/get_local_profile.rs"] -mod tests; diff --git a/crates/application/src/users/get_page_viewer.rs b/crates/application/src/users/get_page_viewer.rs index f2e7d24c..64927bf6 100644 --- a/crates/application/src/users/get_page_viewer.rs +++ b/crates/application/src/users/get_page_viewer.rs @@ -38,7 +38,3 @@ pub async fn execute(deps: &GetPageViewerDeps, user_id: Uuid) -> Result>>, envelope: EventEnve tracing::error!("ack failed: {e}"); } } - -#[cfg(test)] -#[path = "tests/worker.rs"] -mod tests; diff --git a/crates/application/src/wrapup/compute.rs b/crates/application/src/wrapup/compute.rs index 5a4b56e7..0a857566 100644 --- a/crates/application/src/wrapup/compute.rs +++ b/crates/application/src/wrapup/compute.rs @@ -19,7 +19,3 @@ pub async fn execute( &rows, )) } - -#[cfg(test)] -#[path = "tests/compute.rs"] -mod tests; diff --git a/crates/application/src/wrapup/delete.rs b/crates/application/src/wrapup/delete.rs index 84ac0ef9..2d72f524 100644 --- a/crates/application/src/wrapup/delete.rs +++ b/crates/application/src/wrapup/delete.rs @@ -11,7 +11,3 @@ pub async fn execute(deps: &DeleteWrapUpDeps, id: WrapUpId) -> Result<(), Domain deps.wrapup_repo.delete(&id).await } - -#[cfg(test)] -#[path = "tests/delete.rs"] -mod tests; diff --git a/crates/application/src/wrapup/generate.rs b/crates/application/src/wrapup/generate.rs index 01dd5d1c..f560baf6 100644 --- a/crates/application/src/wrapup/generate.rs +++ b/crates/application/src/wrapup/generate.rs @@ -59,7 +59,3 @@ pub async fn execute( Ok(id) } - -#[cfg(test)] -#[path = "tests/generate.rs"] -mod tests; diff --git a/crates/application/src/wrapup/get_ready_report.rs b/crates/application/src/wrapup/get_ready_report.rs index fc92654c..8edc7e85 100644 --- a/crates/application/src/wrapup/get_ready_report.rs +++ b/crates/application/src/wrapup/get_ready_report.rs @@ -30,7 +30,3 @@ pub async fn execute( .report .ok_or_else(|| DomainError::NotFound("wrap-up report".into())) } - -#[cfg(test)] -#[path = "tests/get_ready_report.rs"] -mod tests; diff --git a/crates/application/src/wrapup/get_wrapup.rs b/crates/application/src/wrapup/get_wrapup.rs index 0613849f..a2cb1518 100644 --- a/crates/application/src/wrapup/get_wrapup.rs +++ b/crates/application/src/wrapup/get_wrapup.rs @@ -10,7 +10,3 @@ pub async fn execute( ) -> Result, DomainError> { deps.wrapup_repo.get_by_id(&id).await } - -#[cfg(test)] -#[path = "tests/get_wrapup.rs"] -mod tests; diff --git a/crates/application/src/wrapup/handle_requested.rs b/crates/application/src/wrapup/handle_requested.rs index 0b86e46d..70a93bfb 100644 --- a/crates/application/src/wrapup/handle_requested.rs +++ b/crates/application/src/wrapup/handle_requested.rs @@ -52,7 +52,3 @@ pub async fn execute( } } } - -#[cfg(test)] -#[path = "tests/handle_requested.rs"] -mod tests; diff --git a/crates/application/src/wrapup/list_wrapups.rs b/crates/application/src/wrapup/list_wrapups.rs index c270158c..e4235cb2 100644 --- a/crates/application/src/wrapup/list_wrapups.rs +++ b/crates/application/src/wrapup/list_wrapups.rs @@ -18,7 +18,3 @@ pub async fn execute( None => deps.wrapup_repo.list_global().await, } } - -#[cfg(test)] -#[path = "tests/list_wrapups.rs"] -mod tests; diff --git a/crates/application/tests/auth.rs b/crates/application/tests/auth.rs new file mode 100644 index 00000000..2d11147f --- /dev/null +++ b/crates/application/tests/auth.rs @@ -0,0 +1,12 @@ +mod support; + +#[path = "auth/login_test.rs"] +mod login_test; +#[path = "auth/logout_test.rs"] +mod logout_test; +#[path = "auth/refresh_test.rs"] +mod refresh_test; +#[path = "auth/register_and_login_test.rs"] +mod register_and_login_test; +#[path = "auth/register_test.rs"] +mod register_test; diff --git a/crates/application/src/auth/tests/login.rs b/crates/application/tests/auth/login_test.rs similarity index 85% rename from crates/application/src/auth/tests/login.rs rename to crates/application/tests/auth/login_test.rs index 6b422981..492bdbd9 100644 --- a/crates/application/src/auth/tests/login.rs +++ b/crates/application/tests/auth/login_test.rs @@ -1,15 +1,13 @@ -use crate::test_support::{login_command, register_command}; +use crate::support::TestContextBuilder; +use crate::support::{login_command, register_command}; use std::sync::Arc; use domain::testing::InMemoryStore; -use crate::{ - auth::{ - commands::RegisterCommand, - deps::{LoginDeps, RegisterDeps}, - login, register, - }, - test_helpers::TestContextBuilder, +use application::auth::{ + commands::RegisterCommand, + deps::{LoginDeps, RegisterDeps}, + login, register, }; async fn setup_user(b: &TestContextBuilder, email: &str, password: &str) { @@ -30,7 +28,7 @@ async fn setup_user(b: &TestContextBuilder, email: &str, password: &str) { } #[tokio::test] -async fn test_login_valid_credentials_returns_token() { +async fn login_with_valid_credentials_returns_a_token() { let users = InMemoryStore::new(); let b = TestContextBuilder::new().with_users(Arc::clone(&users) as _); setup_user(&b, "carol@example.com", "secret123").await; @@ -52,7 +50,7 @@ async fn test_login_valid_credentials_returns_token() { } #[tokio::test] -async fn test_login_wrong_password_fails() { +async fn login_with_the_wrong_password_fails() { let users = InMemoryStore::new(); let b = TestContextBuilder::new().with_users(Arc::clone(&users) as _); setup_user(&b, "dave@example.com", "correct_password").await; @@ -70,7 +68,7 @@ async fn test_login_wrong_password_fails() { } #[tokio::test] -async fn test_login_unknown_email_fails() { +async fn login_with_an_unknown_email_fails() { let b = TestContextBuilder::new(); let deps = LoginDeps { user: b.user_repo.clone(), diff --git a/crates/application/src/auth/tests/logout.rs b/crates/application/tests/auth/logout_test.rs similarity index 87% rename from crates/application/src/auth/tests/logout.rs rename to crates/application/tests/auth/logout_test.rs index 582cf530..fec5de05 100644 --- a/crates/application/src/auth/tests/logout.rs +++ b/crates/application/tests/auth/logout_test.rs @@ -1,14 +1,12 @@ -use crate::test_support::{login_command, register_command}; +use crate::support::TestContextBuilder; +use crate::support::{login_command, register_command}; use std::sync::Arc; use domain::testing::InMemoryStore; -use crate::{ - auth::{ - deps::{LoginDeps, LogoutDeps, RefreshDeps, RegisterDeps}, - login, logout, refresh, register, - }, - test_helpers::TestContextBuilder, +use application::auth::{ + deps::{LoginDeps, LogoutDeps, RefreshDeps, RegisterDeps}, + login, logout, refresh, register, }; #[tokio::test] diff --git a/crates/application/src/auth/tests/refresh.rs b/crates/application/tests/auth/refresh_test.rs similarity index 93% rename from crates/application/src/auth/tests/refresh.rs rename to crates/application/tests/auth/refresh_test.rs index cbaf3c77..7161731f 100644 --- a/crates/application/src/auth/tests/refresh.rs +++ b/crates/application/tests/auth/refresh_test.rs @@ -1,14 +1,12 @@ -use crate::test_support::{login_command, register_command}; +use crate::support::TestContextBuilder; +use crate::support::{login_command, register_command}; use std::sync::Arc; use domain::testing::InMemoryStore; -use crate::{ - auth::{ - deps::{LoginDeps, RefreshDeps, RegisterDeps}, - login, refresh, register, - }, - test_helpers::TestContextBuilder, +use application::auth::{ + deps::{LoginDeps, RefreshDeps, RegisterDeps}, + login, refresh, register, }; async fn login_user(b: &TestContextBuilder) -> login::LoginResult { diff --git a/crates/application/src/auth/tests/register_and_login.rs b/crates/application/tests/auth/register_and_login_test.rs similarity index 78% rename from crates/application/src/auth/tests/register_and_login.rs rename to crates/application/tests/auth/register_and_login_test.rs index 79eadaf4..5318753d 100644 --- a/crates/application/src/auth/tests/register_and_login.rs +++ b/crates/application/tests/auth/register_and_login_test.rs @@ -1,7 +1,7 @@ -use crate::auth::commands::RegisterAndLoginCommand; -use crate::auth::deps::RegisterAndLoginDeps; -use crate::auth::register_and_login; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::auth::commands::RegisterAndLoginCommand; +use application::auth::deps::RegisterAndLoginDeps; +use application::auth::register_and_login; #[tokio::test] async fn registers_and_returns_token() { diff --git a/crates/application/src/auth/tests/register.rs b/crates/application/tests/auth/register_test.rs similarity index 86% rename from crates/application/src/auth/tests/register.rs rename to crates/application/tests/auth/register_test.rs index 71025243..e28f30be 100644 --- a/crates/application/src/auth/tests/register.rs +++ b/crates/application/tests/auth/register_test.rs @@ -1,21 +1,19 @@ -use crate::test_support::register_command; +use crate::support::TestContextBuilder; +use crate::support::register_command; use std::sync::Arc; use domain::ports::UserRepository; use domain::testing::InMemoryStore; use domain::value_objects::Email; -use crate::{ - auth::{commands::RegisterCommand, deps::RegisterDeps, register}, - test_helpers::TestContextBuilder, -}; +use application::auth::{commands::RegisterCommand, deps::RegisterDeps, register}; fn cmd(email: &str) -> RegisterCommand { register_command(email, "alice") } #[tokio::test] -async fn test_register_creates_user() { +async fn registering_creates_the_user() { let users = InMemoryStore::new(); let b = TestContextBuilder::new().with_users(Arc::clone(&users) as _); let deps = RegisterDeps { @@ -35,7 +33,7 @@ async fn test_register_creates_user() { } #[tokio::test] -async fn test_register_duplicate_email_fails() { +async fn registering_with_a_duplicate_email_fails() { let users = InMemoryStore::new(); let b = TestContextBuilder::new().with_users(Arc::clone(&users) as _); let deps = RegisterDeps { @@ -52,7 +50,7 @@ async fn test_register_duplicate_email_fails() { } #[tokio::test] -async fn test_register_short_password_fails() { +async fn registering_with_a_short_password_fails() { let b = TestContextBuilder::new(); let deps = RegisterDeps { user: b.user_repo.clone(), diff --git a/crates/application/tests/diary.rs b/crates/application/tests/diary.rs new file mode 100644 index 00000000..2850e033 --- /dev/null +++ b/crates/application/tests/diary.rs @@ -0,0 +1,22 @@ +mod support; + +#[path = "diary/delete_review_test.rs"] +mod delete_review_test; +#[path = "diary/edit_review_test.rs"] +mod edit_review_test; +#[path = "diary/get_activity_feed_test.rs"] +mod get_activity_feed_test; +#[path = "diary/get_diary_test.rs"] +mod get_diary_test; +#[path = "diary/get_movie_social_page_test.rs"] +mod get_movie_social_page_test; +#[path = "diary/get_review_history_test.rs"] +mod get_review_history_test; +#[path = "diary/get_user_feed_test.rs"] +mod get_user_feed_test; +#[path = "diary/log_review_test.rs"] +mod log_review_test; +#[path = "diary/movie_resolver_test.rs"] +mod movie_resolver_test; +#[path = "diary/review_logger_test.rs"] +mod review_logger_test; diff --git a/crates/application/src/diary/tests/delete_review.rs b/crates/application/tests/diary/delete_review_test.rs similarity index 95% rename from crates/application/src/diary/tests/delete_review.rs rename to crates/application/tests/diary/delete_review_test.rs index 121e0d42..9ef43edc 100644 --- a/crates/application/src/diary/tests/delete_review.rs +++ b/crates/application/tests/diary/delete_review_test.rs @@ -7,12 +7,12 @@ use domain::{ value_objects::{MovieId, UserId}, }; -use crate::{ +use application::{ diary::commands::DeleteReviewCommand, diary::delete_review, diary::deps::DeleteReviewDeps, }; #[tokio::test] -async fn test_delete_review_removes_it() { +async fn deleting_a_review_removes_it() { let movies = InMemoryStore::new(); let reviews = Arc::clone(&movies); let diary = FakeDiaryQuery::new(); @@ -51,7 +51,7 @@ async fn test_delete_review_removes_it() { } #[tokio::test] -async fn test_delete_review_wrong_user_is_unauthorized() { +async fn deleting_another_users_review_is_unauthorized() { let reviews = InMemoryStore::new(); let diary = FakeDiaryQuery::new(); let movies = Arc::clone(&reviews); diff --git a/crates/application/src/diary/tests/edit_review.rs b/crates/application/tests/diary/edit_review_test.rs similarity index 97% rename from crates/application/src/diary/tests/edit_review.rs rename to crates/application/tests/diary/edit_review_test.rs index e47e3d7b..da78fd4c 100644 --- a/crates/application/src/diary/tests/edit_review.rs +++ b/crates/application/tests/diary/edit_review_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::edit_review_command; +use crate::support::edit_review_command; use std::sync::Arc; use domain::{ @@ -8,7 +8,7 @@ use domain::{ value_objects::{Comment, MovieId, ReviewId, UserId, WatchMedium}, }; -use crate::diary::{commands::EditReviewCommand, deps::EditReviewDeps, edit_review}; +use application::diary::{commands::EditReviewCommand, deps::EditReviewDeps, edit_review}; async fn setup() -> ( Arc, diff --git a/crates/application/src/diary/tests/get_activity_feed.rs b/crates/application/tests/diary/get_activity_feed_test.rs similarity index 96% rename from crates/application/src/diary/tests/get_activity_feed.rs rename to crates/application/tests/diary/get_activity_feed_test.rs index 7e923f56..4fe14907 100644 --- a/crates/application/src/diary/tests/get_activity_feed.rs +++ b/crates/application/tests/diary/get_activity_feed_test.rs @@ -1,3 +1,4 @@ +use crate::support::TestContextBuilder; use std::sync::Arc; use async_trait::async_trait; @@ -5,9 +6,9 @@ use domain::errors::DomainError; use domain::testing::InMemoryStore; use domain::value_objects::{FollowRelation, SocialActor, SocialIdentity, UserId}; -use crate::{ +use application::{ config::AppConfig, diary::deps::GetActivityFeedDeps, diary::get_activity_feed, - diary::queries::GetActivityFeedQuery, test_helpers::TestContextBuilder, + diary::queries::GetActivityFeedQuery, }; fn default_deps() -> GetActivityFeedDeps { @@ -131,7 +132,7 @@ async fn following_filter_separates_local_and_remote() { refresh_ttl_seconds: 2_592_000, secure_cookies: false, cors_origins: String::new(), - wrapup: crate::config::WrapUpConfig { + wrapup: application::config::WrapUpConfig { font_path: None, logo_path: None, bg_dir: None, diff --git a/crates/application/src/diary/tests/get_diary.rs b/crates/application/tests/diary/get_diary_test.rs similarity index 85% rename from crates/application/src/diary/tests/get_diary.rs rename to crates/application/tests/diary/get_diary_test.rs index 5a2fd04c..382ae19b 100644 --- a/crates/application/src/diary/tests/get_diary.rs +++ b/crates/application/tests/diary/get_diary_test.rs @@ -1,7 +1,7 @@ use domain::testing::FakeDiaryQuery; use std::sync::Arc; -use crate::{diary::deps::GetDiaryDeps, diary::get_diary, diary::queries::GetDiaryQuery}; +use application::{diary::deps::GetDiaryDeps, diary::get_diary, diary::queries::GetDiaryQuery}; #[tokio::test] async fn returns_empty_page() { diff --git a/crates/application/src/diary/tests/get_movie_social_page.rs b/crates/application/tests/diary/get_movie_social_page_test.rs similarity index 98% rename from crates/application/src/diary/tests/get_movie_social_page.rs rename to crates/application/tests/diary/get_movie_social_page_test.rs index dfab284d..60f91880 100644 --- a/crates/application/src/diary/tests/get_movie_social_page.rs +++ b/crates/application/tests/diary/get_movie_social_page_test.rs @@ -8,7 +8,7 @@ use domain::{ testing::{FakeDiaryQuery, InMemoryStore}, }; -use crate::{ +use application::{ diary::deps::GetMovieSocialPageDeps, diary::get_movie_social_page, diary::queries::GetMovieSocialPageQuery, }; diff --git a/crates/application/src/diary/tests/get_review_history.rs b/crates/application/tests/diary/get_review_history_test.rs similarity index 97% rename from crates/application/src/diary/tests/get_review_history.rs rename to crates/application/tests/diary/get_review_history_test.rs index 6306e956..774826b9 100644 --- a/crates/application/src/diary/tests/get_review_history.rs +++ b/crates/application/tests/diary/get_review_history_test.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use domain::{ports::DiaryQuery, services::review_history::Trend}; -use crate::{ +use application::{ diary::deps::GetReviewHistoryDeps, diary::get_review_history, diary::queries::GetReviewHistoryQuery, }; diff --git a/crates/application/src/diary/tests/get_user_feed.rs b/crates/application/tests/diary/get_user_feed_test.rs similarity index 89% rename from crates/application/src/diary/tests/get_user_feed.rs rename to crates/application/tests/diary/get_user_feed_test.rs index 6ada6df8..7b890a9c 100644 --- a/crates/application/src/diary/tests/get_user_feed.rs +++ b/crates/application/tests/diary/get_user_feed_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::register_command; +use crate::support::register_command; use domain::testing::{test_movie_with_year, test_review}; use std::sync::Arc; @@ -9,11 +9,11 @@ use domain::models::{DiaryEntry, collections::Paginated}; use domain::testing::FakeDiaryQuery; use domain::value_objects::{Email, UserId}; -use crate::auth::deps::RegisterDeps; -use crate::auth::register; -use crate::diary::deps::GetUserFeedDeps; -use crate::diary::get_user_feed; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::auth::deps::RegisterDeps; +use application::auth::register; +use application::diary::deps::GetUserFeedDeps; +use application::diary::get_user_feed; async fn setup_user(b: &TestContextBuilder, email: &str, username: &str) { let deps = RegisterDeps { diff --git a/crates/application/src/diary/tests/log_review.rs b/crates/application/tests/diary/log_review_test.rs similarity index 82% rename from crates/application/src/diary/tests/log_review.rs rename to crates/application/tests/diary/log_review_test.rs index 78f11a32..3dc95590 100644 --- a/crates/application/src/diary/tests/log_review.rs +++ b/crates/application/tests/diary/log_review_test.rs @@ -1,4 +1,5 @@ -use crate::test_support::{log_review_command, log_review_command_manual}; +use crate::support::TestContextBuilder; +use crate::support::{log_review_command, log_review_command_manual}; use domain::testing::test_movie_with_year; use std::sync::Arc; @@ -6,16 +7,15 @@ use domain::ports::MovieCommand; use domain::testing::{InMemoryStore, NoopEventPublisher}; -use crate::{ - diary::commands::LogReviewCommand, diary::log_review, - diary::review_logger::DefaultReviewLogger, test_helpers::TestContextBuilder, +use application::{ + diary::commands::LogReviewCommand, diary::log_review, diary::review_logger::DefaultReviewLogger, }; fn build_logger( movies: &Arc, reviews: &Arc, events: &Arc, -) -> Arc { +) -> Arc { Arc::new(DefaultReviewLogger::new( Arc::clone(movies) as _, Arc::clone(movies) as _, @@ -27,7 +27,7 @@ fn build_logger( } #[tokio::test] -async fn test_log_review_creates_movie_and_review() { +async fn logging_a_review_creates_the_movie_and_the_review() { let movies = InMemoryStore::new(); let reviews = Arc::clone(&movies); let events = NoopEventPublisher::new(); @@ -43,7 +43,7 @@ async fn test_log_review_creates_movie_and_review() { } #[tokio::test] -async fn test_log_review_reuses_existing_movie() { +async fn logging_a_review_reuses_an_existing_movie() { let movies = InMemoryStore::new(); let reviews = Arc::clone(&movies); @@ -66,7 +66,7 @@ async fn test_log_review_reuses_existing_movie() { } #[tokio::test] -async fn test_log_review_with_invalid_rating_fails() { +async fn logging_a_review_with_an_invalid_rating_fails() { let movies = InMemoryStore::new(); let reviews = Arc::clone(&movies); let events = NoopEventPublisher::new(); diff --git a/crates/application/src/diary/tests/movie_resolver.rs b/crates/application/tests/diary/movie_resolver_test.rs similarity index 98% rename from crates/application/src/diary/tests/movie_resolver.rs rename to crates/application/tests/diary/movie_resolver_test.rs index 7387c9ad..53b38482 100644 --- a/crates/application/src/diary/tests/movie_resolver.rs +++ b/crates/application/tests/diary/movie_resolver_test.rs @@ -1,5 +1,6 @@ -use super::*; -use crate::diary::commands::MovieInput; +use application::diary::commands::MovieInput; +use application::diary::movie_resolver::*; +use domain::ports::MetadataClient; use domain::testing::test_movie_with_year; use domain::{ errors::DomainError, diff --git a/crates/application/src/diary/tests/review_logger.rs b/crates/application/tests/diary/review_logger_test.rs similarity index 97% rename from crates/application/src/diary/tests/review_logger.rs rename to crates/application/tests/diary/review_logger_test.rs index 6e070ab1..98e76180 100644 --- a/crates/application/src/diary/tests/review_logger.rs +++ b/crates/application/tests/diary/review_logger_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::{log_review_command, log_review_command_manual}; +use crate::support::{log_review_command, log_review_command_manual}; use domain::testing::{test_movie_with_external_id, test_movie_with_year}; use std::sync::Arc; @@ -13,9 +13,9 @@ use domain::{ }; use uuid::Uuid; -use crate::diary::commands::LogReviewCommand; -use crate::diary::review_logger::DefaultReviewLogger; -use crate::ports::ReviewLogger; +use application::diary::commands::LogReviewCommand; +use application::diary::review_logger::DefaultReviewLogger; +use application::ports::ReviewLogger; fn make_logger( movies: &Arc, diff --git a/crates/application/tests/goals.rs b/crates/application/tests/goals.rs new file mode 100644 index 00000000..d91c5f58 --- /dev/null +++ b/crates/application/tests/goals.rs @@ -0,0 +1,12 @@ +mod support; + +#[path = "goals/create_test.rs"] +mod create_test; +#[path = "goals/delete_test.rs"] +mod delete_test; +#[path = "goals/get_test.rs"] +mod get_test; +#[path = "goals/list_test.rs"] +mod list_test; +#[path = "goals/update_test.rs"] +mod update_test; diff --git a/crates/application/src/goals/tests/create.rs b/crates/application/tests/goals/create_test.rs similarity index 95% rename from crates/application/src/goals/tests/create.rs rename to crates/application/tests/goals/create_test.rs index a4996fcd..7bc05398 100644 --- a/crates/application/src/goals/tests/create.rs +++ b/crates/application/tests/goals/create_test.rs @@ -1,13 +1,13 @@ -use crate::test_support::create_goal_command; +use crate::support::create_goal_command; use std::sync::Arc; use domain::events::DomainEvent; use domain::testing::{FakeStatsRepository, InMemoryStore, NoopEventPublisher}; use uuid::Uuid; -use crate::goals::create; -use crate::goals::deps::GoalCommandDeps; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::goals::create; +use application::goals::deps::GoalCommandDeps; #[tokio::test] async fn creates_goal_and_returns_progress() { diff --git a/crates/application/src/goals/tests/delete.rs b/crates/application/tests/goals/delete_test.rs similarity index 87% rename from crates/application/src/goals/tests/delete.rs rename to crates/application/tests/goals/delete_test.rs index 6ff2d425..86d8de0f 100644 --- a/crates/application/src/goals/tests/delete.rs +++ b/crates/application/tests/goals/delete_test.rs @@ -1,12 +1,12 @@ -use crate::test_support::create_goal_command; +use crate::support::create_goal_command; use std::sync::Arc; use domain::testing::{FakeStatsRepository, InMemoryStore, NoopEventPublisher}; use uuid::Uuid; -use crate::goals::deps::GoalCommandDeps; -use crate::goals::{commands::DeleteGoalCommand, create, delete}; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::goals::deps::GoalCommandDeps; +use application::goals::{commands::DeleteGoalCommand, create, delete}; #[tokio::test] async fn deletes_existing_goal() { diff --git a/crates/application/src/goals/tests/get.rs b/crates/application/tests/goals/get_test.rs similarity index 85% rename from crates/application/src/goals/tests/get.rs rename to crates/application/tests/goals/get_test.rs index 020b63e9..a4562bdf 100644 --- a/crates/application/src/goals/tests/get.rs +++ b/crates/application/tests/goals/get_test.rs @@ -1,9 +1,9 @@ -use crate::test_support::create_goal_command; +use crate::support::create_goal_command; use uuid::Uuid; -use crate::goals::deps::{GoalCommandDeps, GoalQueryDeps}; -use crate::goals::{create, get, queries::GetGoalQuery}; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::goals::deps::{GoalCommandDeps, GoalQueryDeps}; +use application::goals::{create, get, queries::GetGoalQuery}; #[tokio::test] async fn returns_goal_when_exists() { diff --git a/crates/application/src/goals/tests/list.rs b/crates/application/tests/goals/list_test.rs similarity index 85% rename from crates/application/src/goals/tests/list.rs rename to crates/application/tests/goals/list_test.rs index 05d8e688..430c3d45 100644 --- a/crates/application/src/goals/tests/list.rs +++ b/crates/application/tests/goals/list_test.rs @@ -1,9 +1,9 @@ -use crate::test_support::create_goal_command; +use crate::support::create_goal_command; use uuid::Uuid; -use crate::goals::deps::{GoalCommandDeps, GoalQueryDeps}; -use crate::goals::{create, list, queries::ListGoalsQuery}; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::goals::deps::{GoalCommandDeps, GoalQueryDeps}; +use application::goals::{create, list, queries::ListGoalsQuery}; #[tokio::test] async fn returns_empty_when_no_goals() { diff --git a/crates/application/src/goals/tests/update.rs b/crates/application/tests/goals/update_test.rs similarity index 88% rename from crates/application/src/goals/tests/update.rs rename to crates/application/tests/goals/update_test.rs index 9ec7e650..7d7bac10 100644 --- a/crates/application/src/goals/tests/update.rs +++ b/crates/application/tests/goals/update_test.rs @@ -1,8 +1,8 @@ -use crate::test_support::{create_goal_command, update_goal_command}; +use crate::support::{create_goal_command, update_goal_command}; -use crate::goals::deps::GoalCommandDeps; -use crate::goals::{create, update}; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::goals::deps::GoalCommandDeps; +use application::goals::{create, update}; #[tokio::test] async fn updates_target_count() { diff --git a/crates/application/tests/import.rs b/crates/application/tests/import.rs new file mode 100644 index 00000000..ca5dd921 --- /dev/null +++ b/crates/application/tests/import.rs @@ -0,0 +1,26 @@ +mod support; + +#[path = "import/apply_mapping_test.rs"] +mod apply_mapping_test; +#[path = "import/apply_profile_and_map_test.rs"] +mod apply_profile_and_map_test; +#[path = "import/apply_profile_test.rs"] +mod apply_profile_test; +#[path = "import/cleanup_test.rs"] +mod cleanup_test; +#[path = "import/create_session_test.rs"] +mod create_session_test; +#[path = "import/delete_profile_test.rs"] +mod delete_profile_test; +#[path = "import/execute_test.rs"] +mod execute_test; +#[path = "import/get_mapping_stage_test.rs"] +mod get_mapping_stage_test; +#[path = "import/get_preview_stage_test.rs"] +mod get_preview_stage_test; +#[path = "import/get_session_state_test.rs"] +mod get_session_state_test; +#[path = "import/list_profiles_test.rs"] +mod list_profiles_test; +#[path = "import/save_profile_test.rs"] +mod save_profile_test; diff --git a/crates/application/src/import/tests/apply_mapping.rs b/crates/application/tests/import/apply_mapping_test.rs similarity index 95% rename from crates/application/src/import/tests/apply_mapping.rs rename to crates/application/tests/import/apply_mapping_test.rs index 57179cd1..c5749e0a 100644 --- a/crates/application/src/import/tests/apply_mapping.rs +++ b/crates/application/tests/import/apply_mapping_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::{apply_import_mapping_command, create_import_session_command}; +use crate::support::{apply_import_mapping_command, create_import_session_command}; use domain::testing::{test_movie_with_external_id, test_movie_with_year}; use std::sync::Arc; @@ -14,9 +14,9 @@ use domain::{ value_objects::ExternalMetadataId, }; -use crate::import::deps::{ApplyMappingDeps, CreateSessionDeps}; -use crate::import::{apply_mapping, create_session}; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::import::deps::{ApplyMappingDeps, CreateSessionDeps}; +use application::import::{apply_mapping, create_session}; #[tokio::test] async fn applies_mapping_to_session() { diff --git a/crates/application/src/import/tests/apply_profile_and_map.rs b/crates/application/tests/import/apply_profile_and_map_test.rs similarity index 91% rename from crates/application/src/import/tests/apply_profile_and_map.rs rename to crates/application/tests/import/apply_profile_and_map_test.rs index b4b390d5..18b05647 100644 --- a/crates/application/src/import/tests/apply_profile_and_map.rs +++ b/crates/application/tests/import/apply_profile_and_map_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::create_import_session_command; +use crate::support::create_import_session_command; use std::sync::Arc; use chrono::Utc; @@ -10,9 +10,11 @@ use domain::ports::{ImportProfileRepository, ImportSessionRepository}; use domain::testing::InMemoryStore; use domain::value_objects::{ImportProfileId, UserId}; -use crate::import::deps::{ApplyProfileAndMapDeps, CreateSessionDeps}; -use crate::import::{apply_profile_and_map, commands::ApplyProfileAndMapCommand, create_session}; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::import::deps::{ApplyProfileAndMapDeps, CreateSessionDeps}; +use application::import::{ + apply_profile_and_map, commands::ApplyProfileAndMapCommand, create_session, +}; #[tokio::test] async fn fails_when_profile_not_found() { diff --git a/crates/application/src/import/tests/apply_profile.rs b/crates/application/tests/import/apply_profile_test.rs similarity index 95% rename from crates/application/src/import/tests/apply_profile.rs rename to crates/application/tests/import/apply_profile_test.rs index 7420a5fd..1a6068cd 100644 --- a/crates/application/src/import/tests/apply_profile.rs +++ b/crates/application/tests/import/apply_profile_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::apply_import_profile_command; +use crate::support::apply_import_profile_command; use std::sync::Arc; use chrono::Utc; @@ -8,8 +8,8 @@ use domain::testing::InMemoryStore; use domain::value_objects::{ImportProfileId, UserId}; use uuid::Uuid; -use crate::import::apply_profile; -use crate::import::deps::ApplyProfileDeps; +use application::import::apply_profile; +use application::import::deps::ApplyProfileDeps; #[tokio::test] async fn fails_when_profile_not_found() { diff --git a/crates/application/src/import/tests/cleanup.rs b/crates/application/tests/import/cleanup_test.rs similarity index 88% rename from crates/application/src/import/tests/cleanup.rs rename to crates/application/tests/import/cleanup_test.rs index 3302099e..90ef0787 100644 --- a/crates/application/src/import/tests/cleanup.rs +++ b/crates/application/tests/import/cleanup_test.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use domain::testing::InMemoryStore; -use crate::import::cleanup; +use application::import::cleanup; #[tokio::test] async fn returns_zero_when_nothing_expired() { diff --git a/crates/application/src/import/tests/create_session.rs b/crates/application/tests/import/create_session_test.rs similarity index 75% rename from crates/application/src/import/tests/create_session.rs rename to crates/application/tests/import/create_session_test.rs index 19119518..39f3ed4d 100644 --- a/crates/application/src/import/tests/create_session.rs +++ b/crates/application/tests/import/create_session_test.rs @@ -1,13 +1,13 @@ -use crate::test_support::create_import_session_command; +use crate::support::create_import_session_command; use std::sync::Arc; use uuid::Uuid; use domain::testing::InMemoryStore; -use crate::import::create_session; -use crate::import::deps::CreateSessionDeps; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::import::create_session; +use application::import::deps::CreateSessionDeps; #[tokio::test] async fn creates_session_with_parsed_file() { diff --git a/crates/application/src/import/tests/delete_profile.rs b/crates/application/tests/import/delete_profile_test.rs similarity index 95% rename from crates/application/src/import/tests/delete_profile.rs rename to crates/application/tests/import/delete_profile_test.rs index 79f89d18..091fca72 100644 --- a/crates/application/src/import/tests/delete_profile.rs +++ b/crates/application/tests/import/delete_profile_test.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use domain::testing::InMemoryStore; use uuid::Uuid; -use crate::import::{ +use application::import::{ commands::DeleteImportProfileCommand, delete_profile, deps::DeleteImportProfileDeps, }; diff --git a/crates/application/src/import/tests/execute.rs b/crates/application/tests/import/execute_test.rs similarity index 98% rename from crates/application/src/import/tests/execute.rs rename to crates/application/tests/import/execute_test.rs index fc2ca7ab..45b2349a 100644 --- a/crates/application/src/import/tests/execute.rs +++ b/crates/application/tests/import/execute_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::execute_import_command; +use crate::support::execute_import_command; use std::sync::Arc; use domain::models::{AnnotatedRow, ImportSession, import::RowResult}; @@ -7,10 +7,10 @@ use domain::testing::InMemoryStore; use domain::value_objects::UserId; use uuid::Uuid; -use crate::import::commands::ExecuteImportCommand; -use crate::import::deps::ExecuteImportDeps; -use crate::import::execute; -use crate::test_helpers::NoopReviewLogger; +use crate::support::NoopReviewLogger; +use application::import::commands::ExecuteImportCommand; +use application::import::deps::ExecuteImportDeps; +use application::import::execute; fn make_session_with_rows(user_id: UserId) -> ImportSession { let mut session = ImportSession::new(user_id); diff --git a/crates/application/src/import/tests/get_mapping_stage.rs b/crates/application/tests/import/get_mapping_stage_test.rs similarity index 94% rename from crates/application/src/import/tests/get_mapping_stage.rs rename to crates/application/tests/import/get_mapping_stage_test.rs index d33392f7..6c7b8855 100644 --- a/crates/application/src/import/tests/get_mapping_stage.rs +++ b/crates/application/tests/import/get_mapping_stage_test.rs @@ -8,8 +8,8 @@ use domain::ports::ImportSessionRepository; use domain::testing::InMemoryStore; use domain::value_objects::{ImportSessionId, UserId}; -use crate::import::deps::GetMappingStageDeps; -use crate::import::get_mapping_stage::{self, SAMPLE_ROW_LIMIT}; +use application::import::deps::GetMappingStageDeps; +use application::import::get_mapping_stage::{self, SAMPLE_ROW_LIMIT}; #[tokio::test] async fn get_mapping_stage_is_not_found_when_file_not_parsed() { diff --git a/crates/application/src/import/tests/get_preview_stage.rs b/crates/application/tests/import/get_preview_stage_test.rs similarity index 95% rename from crates/application/src/import/tests/get_preview_stage.rs rename to crates/application/tests/import/get_preview_stage_test.rs index a8644d3e..d3c9585e 100644 --- a/crates/application/src/import/tests/get_preview_stage.rs +++ b/crates/application/tests/import/get_preview_stage_test.rs @@ -8,8 +8,8 @@ use domain::ports::ImportSessionRepository; use domain::testing::InMemoryStore; use domain::value_objects::{ImportSessionId, UserId}; -use crate::import::deps::GetPreviewStageDeps; -use crate::import::get_preview_stage::{self, PreviewStage}; +use application::import::deps::GetPreviewStageDeps; +use application::import::get_preview_stage::{self, PreviewStage}; #[tokio::test] async fn get_preview_stage_reports_not_yet_mapped_when_row_results_absent() { diff --git a/crates/application/src/import/tests/get_session_state.rs b/crates/application/tests/import/get_session_state_test.rs similarity index 93% rename from crates/application/src/import/tests/get_session_state.rs rename to crates/application/tests/import/get_session_state_test.rs index f8d4e218..5cb513fd 100644 --- a/crates/application/src/import/tests/get_session_state.rs +++ b/crates/application/tests/import/get_session_state_test.rs @@ -8,8 +8,8 @@ use domain::ports::ImportSessionRepository; use domain::testing::InMemoryStore; use domain::value_objects::{ImportSessionId, UserId}; -use crate::import::deps::GetSessionStateDeps; -use crate::import::get_session_state; +use application::import::deps::GetSessionStateDeps; +use application::import::get_session_state; #[tokio::test] async fn get_session_state_is_not_found_when_session_missing() { diff --git a/crates/application/src/import/tests/list_profiles.rs b/crates/application/tests/import/list_profiles_test.rs similarity index 86% rename from crates/application/src/import/tests/list_profiles.rs rename to crates/application/tests/import/list_profiles_test.rs index 0fd096e5..384af871 100644 --- a/crates/application/src/import/tests/list_profiles.rs +++ b/crates/application/tests/import/list_profiles_test.rs @@ -4,7 +4,7 @@ use domain::testing::InMemoryStore; use domain::value_objects::UserId; use uuid::Uuid; -use crate::import::{deps::ListImportProfilesDeps, list_profiles}; +use application::import::{deps::ListImportProfilesDeps, list_profiles}; #[tokio::test] async fn returns_empty_when_no_profiles() { diff --git a/crates/application/src/import/tests/save_profile.rs b/crates/application/tests/import/save_profile_test.rs similarity index 92% rename from crates/application/src/import/tests/save_profile.rs rename to crates/application/tests/import/save_profile_test.rs index 4714a5dc..ea13603a 100644 --- a/crates/application/src/import/tests/save_profile.rs +++ b/crates/application/tests/import/save_profile_test.rs @@ -6,8 +6,8 @@ use domain::testing::InMemoryStore; use domain::value_objects::UserId; use uuid::Uuid; -use crate::import::deps::SaveProfileDeps; -use crate::import::{commands::SaveImportProfileCommand, save_profile}; +use application::import::deps::SaveProfileDeps; +use application::import::{commands::SaveImportProfileCommand, save_profile}; #[tokio::test] async fn fails_when_session_not_found() { diff --git a/crates/application/tests/insights.rs b/crates/application/tests/insights.rs new file mode 100644 index 00000000..767e47cd --- /dev/null +++ b/crates/application/tests/insights.rs @@ -0,0 +1,4 @@ +mod support; + +#[path = "insights/get_test.rs"] +mod get_test; diff --git a/crates/application/src/insights/tests/get.rs b/crates/application/tests/insights/get_test.rs similarity index 97% rename from crates/application/src/insights/tests/get.rs rename to crates/application/tests/insights/get_test.rs index c053e507..eec9221a 100644 --- a/crates/application/src/insights/tests/get.rs +++ b/crates/application/tests/insights/get_test.rs @@ -5,7 +5,7 @@ use uuid::Uuid; use domain::{models::insights::WatchRow, testing::InMemoryInsightsQuery, value_objects::UserId}; -use super::*; +use application::insights::{deps::GetInsightsDeps, get::*}; fn watch(genre: &str, rating: u8, day: u32, hour: u32) -> WatchRow { WatchRow { diff --git a/crates/application/tests/integrations.rs b/crates/application/tests/integrations.rs new file mode 100644 index 00000000..b39eecde --- /dev/null +++ b/crates/application/tests/integrations.rs @@ -0,0 +1,18 @@ +mod support; + +#[path = "integrations/cleanup_test.rs"] +mod cleanup_test; +#[path = "integrations/confirm_test.rs"] +mod confirm_test; +#[path = "integrations/dismiss_test.rs"] +mod dismiss_test; +#[path = "integrations/generate_token_test.rs"] +mod generate_token_test; +#[path = "integrations/get_queue_test.rs"] +mod get_queue_test; +#[path = "integrations/get_tokens_test.rs"] +mod get_tokens_test; +#[path = "integrations/ingest_test.rs"] +mod ingest_test; +#[path = "integrations/revoke_token_test.rs"] +mod revoke_token_test; diff --git a/crates/application/src/integrations/tests/cleanup.rs b/crates/application/tests/integrations/cleanup_test.rs similarity index 85% rename from crates/application/src/integrations/tests/cleanup.rs rename to crates/application/tests/integrations/cleanup_test.rs index ec321c62..0209b4ba 100644 --- a/crates/application/src/integrations/tests/cleanup.rs +++ b/crates/application/tests/integrations/cleanup_test.rs @@ -1,6 +1,6 @@ use domain::testing::InMemoryStore; -use crate::integrations::cleanup; +use application::integrations::cleanup; #[tokio::test] async fn returns_zero_when_nothing_to_clean() { diff --git a/crates/application/src/integrations/tests/confirm.rs b/crates/application/tests/integrations/confirm_test.rs similarity index 93% rename from crates/application/src/integrations/tests/confirm.rs rename to crates/application/tests/integrations/confirm_test.rs index a967d22e..79430ce2 100644 --- a/crates/application/src/integrations/tests/confirm.rs +++ b/crates/application/tests/integrations/confirm_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::confirm_watch_events_command; +use crate::support::confirm_watch_events_command; use std::sync::Arc; use domain::models::{WatchEvent, WatchEventSource}; @@ -7,18 +7,18 @@ use domain::testing::{InMemoryStore, NoopEventPublisher}; use domain::value_objects::UserId; use uuid::Uuid; -use crate::integrations::commands::{ConfirmWatchEventsCommand, WatchEventConfirmation}; -use crate::integrations::confirm; -use crate::integrations::deps::ConfirmWatchEventsDeps; -use crate::test_helpers::NoopReviewLogger; +use crate::support::NoopReviewLogger; +use application::integrations::commands::{ConfirmWatchEventsCommand, WatchEventConfirmation}; +use application::integrations::confirm; +use application::integrations::deps::ConfirmWatchEventsDeps; -fn noop_logger() -> Arc { +fn noop_logger() -> Arc { Arc::new(NoopReviewLogger) } fn deps( watch_events: &Arc, - review_logger: Arc, + review_logger: Arc, ) -> ConfirmWatchEventsDeps { ConfirmWatchEventsDeps { watch_event_command: Arc::clone(watch_events) as _, @@ -179,8 +179,8 @@ async fn confirms_event_with_movie_id() { // Build a real review logger let reviews = domain::testing::InMemoryStore::new(); let watchlist = domain::testing::InMemoryStore::new(); - let review_logger: Arc = - Arc::new(crate::diary::review_logger::DefaultReviewLogger::new( + let review_logger: Arc = + Arc::new(application::diary::review_logger::DefaultReviewLogger::new( Arc::clone(&movies) as _, Arc::clone(&movies) as _, Arc::clone(&reviews) as _, diff --git a/crates/application/src/integrations/tests/dismiss.rs b/crates/application/tests/integrations/dismiss_test.rs similarity index 92% rename from crates/application/src/integrations/tests/dismiss.rs rename to crates/application/tests/integrations/dismiss_test.rs index 1ebfdfce..d5278125 100644 --- a/crates/application/src/integrations/tests/dismiss.rs +++ b/crates/application/tests/integrations/dismiss_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::dismiss_watch_events_command; +use crate::support::dismiss_watch_events_command; use std::sync::Arc; use domain::models::{WatchEvent, WatchEventSource}; @@ -7,8 +7,8 @@ use domain::testing::InMemoryStore; use domain::value_objects::UserId; use uuid::Uuid; -use crate::integrations::deps::DismissWatchEventsDeps; -use crate::integrations::dismiss; +use application::integrations::deps::DismissWatchEventsDeps; +use application::integrations::dismiss; fn deps(watch_events: &Arc) -> DismissWatchEventsDeps { DismissWatchEventsDeps { diff --git a/crates/application/src/integrations/tests/generate_token.rs b/crates/application/tests/integrations/generate_token_test.rs similarity index 82% rename from crates/application/src/integrations/tests/generate_token.rs rename to crates/application/tests/integrations/generate_token_test.rs index 80334ac1..3867d53e 100644 --- a/crates/application/src/integrations/tests/generate_token.rs +++ b/crates/application/tests/integrations/generate_token_test.rs @@ -1,12 +1,12 @@ -use crate::test_support::generate_webhook_token_command; +use crate::support::generate_webhook_token_command; use std::sync::Arc; use domain::ports::WebhookTokenRepository; use domain::testing::InMemoryStore; use uuid::Uuid; -use crate::integrations::deps::GenerateWebhookTokenDeps; -use crate::integrations::generate_token; +use application::integrations::deps::GenerateWebhookTokenDeps; +use application::integrations::generate_token; #[tokio::test] async fn generates_token_and_saves() { diff --git a/crates/application/src/integrations/tests/get_queue.rs b/crates/application/tests/integrations/get_queue_test.rs similarity index 90% rename from crates/application/src/integrations/tests/get_queue.rs rename to crates/application/tests/integrations/get_queue_test.rs index 50bacfb4..33d3389d 100644 --- a/crates/application/src/integrations/tests/get_queue.rs +++ b/crates/application/tests/integrations/get_queue_test.rs @@ -7,8 +7,8 @@ use domain::testing::InMemoryStore; use domain::value_objects::UserId; use uuid::Uuid; -use crate::integrations::deps::GetWatchQueueDeps; -use crate::integrations::{get_queue, queries::GetWatchQueueQuery}; +use application::integrations::deps::GetWatchQueueDeps; +use application::integrations::{get_queue, queries::GetWatchQueueQuery}; fn deps(events: &Arc) -> GetWatchQueueDeps { GetWatchQueueDeps { diff --git a/crates/application/src/integrations/tests/get_tokens.rs b/crates/application/tests/integrations/get_tokens_test.rs similarity index 90% rename from crates/application/src/integrations/tests/get_tokens.rs rename to crates/application/tests/integrations/get_tokens_test.rs index 5eedc517..09fe4393 100644 --- a/crates/application/src/integrations/tests/get_tokens.rs +++ b/crates/application/tests/integrations/get_tokens_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::generate_webhook_token_command; +use crate::support::generate_webhook_token_command; use std::sync::Arc; use domain::models::WatchEventSource; @@ -6,8 +6,8 @@ use domain::ports::WebhookTokenRepository; use domain::testing::InMemoryStore; use uuid::Uuid; -use crate::integrations::deps::{GenerateWebhookTokenDeps, GetWebhookTokensDeps}; -use crate::integrations::{ +use application::integrations::deps::{GenerateWebhookTokenDeps, GetWebhookTokensDeps}; +use application::integrations::{ commands::GenerateWebhookTokenCommand, generate_token, get_tokens, queries::GetWebhookTokensQuery, }; diff --git a/crates/application/src/integrations/tests/ingest.rs b/crates/application/tests/integrations/ingest_test.rs similarity index 90% rename from crates/application/src/integrations/tests/ingest.rs rename to crates/application/tests/integrations/ingest_test.rs index 98194231..9f8cc7b0 100644 --- a/crates/application/src/integrations/tests/ingest.rs +++ b/crates/application/tests/integrations/ingest_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::generate_webhook_token_command; +use crate::support::generate_webhook_token_command; use std::sync::Arc; use domain::models::WatchEventSource; @@ -6,9 +6,9 @@ use domain::ports::EventPublisher; use domain::testing::{InMemoryStore, NoopEventPublisher}; use uuid::Uuid; -use crate::integrations::commands::IngestWatchEventCommand; -use crate::integrations::deps::{GenerateWebhookTokenDeps, IngestWatchEventDeps}; -use crate::integrations::{generate_token, ingest}; +use application::integrations::commands::IngestWatchEventCommand; +use application::integrations::deps::{GenerateWebhookTokenDeps, IngestWatchEventDeps}; +use application::integrations::{generate_token, ingest}; struct FakeParser; diff --git a/crates/application/src/integrations/tests/revoke_token.rs b/crates/application/tests/integrations/revoke_token_test.rs similarity index 90% rename from crates/application/src/integrations/tests/revoke_token.rs rename to crates/application/tests/integrations/revoke_token_test.rs index 718ac757..65510f73 100644 --- a/crates/application/src/integrations/tests/revoke_token.rs +++ b/crates/application/tests/integrations/revoke_token_test.rs @@ -1,14 +1,14 @@ -use crate::test_support::generate_webhook_token_command; +use crate::support::generate_webhook_token_command; use std::sync::Arc; use domain::ports::WebhookTokenRepository; use domain::testing::InMemoryStore; use uuid::Uuid; -use crate::integrations::deps::{ +use application::integrations::deps::{ GenerateWebhookTokenDeps, GetWebhookTokensDeps, RevokeWebhookTokenDeps, }; -use crate::integrations::{ +use application::integrations::{ commands::RevokeWebhookTokenCommand, generate_token, get_tokens, queries::GetWebhookTokensQuery, revoke_token, }; diff --git a/crates/application/tests/movies.rs b/crates/application/tests/movies.rs new file mode 100644 index 00000000..5d07e747 --- /dev/null +++ b/crates/application/tests/movies.rs @@ -0,0 +1,12 @@ +mod support; + +#[path = "movies/enrich_movie_test.rs"] +mod enrich_movie_test; +#[path = "movies/get_movie_profile_test.rs"] +mod get_movie_profile_test; +#[path = "movies/get_movies_test.rs"] +mod get_movies_test; +#[path = "movies/request_enrichment_test.rs"] +mod request_enrichment_test; +#[path = "movies/sync_poster_test.rs"] +mod sync_poster_test; diff --git a/crates/application/src/movies/tests/enrich_movie.rs b/crates/application/tests/movies/enrich_movie_test.rs similarity index 97% rename from crates/application/src/movies/tests/enrich_movie.rs rename to crates/application/tests/movies/enrich_movie_test.rs index a6ef9eab..83d090ab 100644 --- a/crates/application/src/movies/tests/enrich_movie.rs +++ b/crates/application/tests/movies/enrich_movie_test.rs @@ -9,7 +9,7 @@ use domain::{ value_objects::MovieId, }; -use crate::movies::{commands::EnrichMovieCommand, deps::EnrichMovieDeps, enrich_movie}; +use application::movies::{commands::EnrichMovieCommand, deps::EnrichMovieDeps, enrich_movie}; #[tokio::test] async fn stores_profile_and_indexes() { diff --git a/crates/application/src/movies/tests/get_movie_profile.rs b/crates/application/tests/movies/get_movie_profile_test.rs similarity index 94% rename from crates/application/src/movies/tests/get_movie_profile.rs rename to crates/application/tests/movies/get_movie_profile_test.rs index 969625ae..b457d6ba 100644 --- a/crates/application/src/movies/tests/get_movie_profile.rs +++ b/crates/application/tests/movies/get_movie_profile_test.rs @@ -8,8 +8,8 @@ use domain::{ value_objects::MovieId, }; -use crate::movies::deps::GetMovieProfileDeps; -use crate::movies::get_movie_profile::{self, GetMovieProfileQuery}; +use application::movies::deps::GetMovieProfileDeps; +use application::movies::get_movie_profile::{self, GetMovieProfileQuery}; #[tokio::test] async fn returns_none_when_no_profile() { diff --git a/crates/application/src/movies/tests/get_movies.rs b/crates/application/tests/movies/get_movies_test.rs similarity index 84% rename from crates/application/src/movies/tests/get_movies.rs rename to crates/application/tests/movies/get_movies_test.rs index 3bb8c49d..45325c27 100644 --- a/crates/application/src/movies/tests/get_movies.rs +++ b/crates/application/tests/movies/get_movies_test.rs @@ -1,6 +1,6 @@ use domain::testing::InMemoryStore; -use crate::movies::{deps::GetMoviesDeps, get_movies, queries::GetMoviesQuery}; +use application::movies::{deps::GetMoviesDeps, get_movies, queries::GetMoviesQuery}; #[tokio::test] async fn returns_empty_when_no_movies() { diff --git a/crates/application/src/movies/tests/request_enrichment.rs b/crates/application/tests/movies/request_enrichment_test.rs similarity index 98% rename from crates/application/src/movies/tests/request_enrichment.rs rename to crates/application/tests/movies/request_enrichment_test.rs index bee95b9d..b2dc79cc 100644 --- a/crates/application/src/movies/tests/request_enrichment.rs +++ b/crates/application/tests/movies/request_enrichment_test.rs @@ -10,7 +10,7 @@ use domain::{ value_objects::MovieId, }; -use crate::movies::request_enrichment; +use application::movies::request_enrichment; #[tokio::test] async fn returns_profile_when_none_cached() { diff --git a/crates/application/src/movies/tests/sync_poster.rs b/crates/application/tests/movies/sync_poster_test.rs similarity index 96% rename from crates/application/src/movies/tests/sync_poster.rs rename to crates/application/tests/movies/sync_poster_test.rs index b9588196..6e2d937c 100644 --- a/crates/application/src/movies/tests/sync_poster.rs +++ b/crates/application/tests/movies/sync_poster_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::sync_poster_command; +use crate::support::sync_poster_command; use domain::testing::{test_movie_with_external_id, test_movie_with_year}; use std::sync::Arc; @@ -12,7 +12,7 @@ use domain::{ value_objects::{ExternalMetadataId, PosterUrl}, }; -use crate::movies::{deps::SyncPosterDeps, sync_poster}; +use application::movies::{deps::SyncPosterDeps, sync_poster}; fn default_deps() -> SyncPosterDeps { SyncPosterDeps { diff --git a/crates/application/tests/person.rs b/crates/application/tests/person.rs new file mode 100644 index 00000000..67ba3ad8 --- /dev/null +++ b/crates/application/tests/person.rs @@ -0,0 +1,6 @@ +mod support; + +#[path = "person/get_credits_test.rs"] +mod get_credits_test; +#[path = "person/get_test.rs"] +mod get_test; diff --git a/crates/application/src/person/tests/get_credits.rs b/crates/application/tests/person/get_credits_test.rs similarity index 89% rename from crates/application/src/person/tests/get_credits.rs rename to crates/application/tests/person/get_credits_test.rs index 0ab6b61c..139477a3 100644 --- a/crates/application/src/person/tests/get_credits.rs +++ b/crates/application/tests/person/get_credits_test.rs @@ -3,7 +3,7 @@ use domain::testing::{FakePersonQuery, NoopEventPublisher}; use std::sync::Arc; use uuid::Uuid; -use crate::person::{deps::GetPersonDeps, get_credits}; +use application::person::{deps::GetPersonDeps, get_credits}; #[tokio::test] async fn returns_empty_credits() { diff --git a/crates/application/src/person/tests/get.rs b/crates/application/tests/person/get_test.rs similarity index 89% rename from crates/application/src/person/tests/get.rs rename to crates/application/tests/person/get_test.rs index 3a1684ae..9b747bed 100644 --- a/crates/application/src/person/tests/get.rs +++ b/crates/application/tests/person/get_test.rs @@ -3,7 +3,7 @@ use domain::testing::{FakePersonQuery, NoopEventPublisher}; use std::sync::Arc; use uuid::Uuid; -use crate::person::{deps::GetPersonDeps, get}; +use application::person::{deps::GetPersonDeps, get}; #[tokio::test] async fn returns_none_for_unknown_person() { diff --git a/crates/application/tests/search.rs b/crates/application/tests/search.rs new file mode 100644 index 00000000..e97757d0 --- /dev/null +++ b/crates/application/tests/search.rs @@ -0,0 +1,4 @@ +mod support; + +#[path = "search/execute_test.rs"] +mod execute_test; diff --git a/crates/application/src/search/tests/execute.rs b/crates/application/tests/search/execute_test.rs similarity index 77% rename from crates/application/src/search/tests/execute.rs rename to crates/application/tests/search/execute_test.rs index db219fa1..452c6227 100644 --- a/crates/application/src/search/tests/execute.rs +++ b/crates/application/tests/search/execute_test.rs @@ -1,8 +1,8 @@ use domain::models::SearchQuery; -use crate::search::deps::SearchDeps; -use crate::search::execute; -use crate::test_helpers::TestContextBuilder; +use crate::support::TestContextBuilder; +use application::search::deps::SearchDeps; +use application::search::execute; #[tokio::test] async fn returns_empty_results() { diff --git a/crates/application/tests/services.rs b/crates/application/tests/services.rs new file mode 100644 index 00000000..a996916a --- /dev/null +++ b/crates/application/tests/services.rs @@ -0,0 +1,4 @@ +mod support; + +#[path = "services/services_test.rs"] +mod services_test; diff --git a/crates/application/src/tests/services.rs b/crates/application/tests/services/services_test.rs similarity index 88% rename from crates/application/src/tests/services.rs rename to crates/application/tests/services/services_test.rs index 17990a55..43aa3054 100644 --- a/crates/application/src/tests/services.rs +++ b/crates/application/tests/services/services_test.rs @@ -1,5 +1,5 @@ -use crate::services::Services; -use crate::test_helpers::NoopReviewLogger; +use crate::support::NoopReviewLogger; +use application::services::Services; use domain::testing::{ FakeAuthService, FakeDocumentParser, FakeMetadataClient, FakePasswordHasher, FakePosterFetcher, NoopEventPublisher, NoopObjectStorage, PanicDiaryExporter, @@ -8,7 +8,7 @@ use std::sync::Arc; #[test] fn services_clone_shares_the_same_port_instances() { - let logger: Arc = Arc::new(NoopReviewLogger); + let logger: Arc = Arc::new(NoopReviewLogger); let s = Services { review_logger: Arc::clone(&logger), person_enrichment: None, diff --git a/crates/application/tests/social.rs b/crates/application/tests/social.rs new file mode 100644 index 00000000..5ab9527e --- /dev/null +++ b/crates/application/tests/social.rs @@ -0,0 +1,6 @@ +mod support; + +#[path = "social/execute_test.rs"] +mod execute_test; +#[path = "social/local_service_test.rs"] +mod local_service_test; diff --git a/crates/application/src/social/tests/execute.rs b/crates/application/tests/social/execute_test.rs similarity index 95% rename from crates/application/src/social/tests/execute.rs rename to crates/application/tests/social/execute_test.rs index 3e907a03..cf8331c3 100644 --- a/crates/application/src/social/tests/execute.rs +++ b/crates/application/tests/social/execute_test.rs @@ -7,7 +7,7 @@ use domain::{ }; use uuid::Uuid; -use crate::social::{ +use application::social::{ commands::SocialCmd, deps::{SocialCommandDeps, SocialQueryDeps}, execute::execute_command, @@ -329,7 +329,7 @@ async fn get_following_returns_accepted_targets() { .await .unwrap(); - let before = crate::social::get_following::execute(&query_deps, follower) + let before = application::social::get_following::execute(&query_deps, follower) .await .unwrap(); assert!( @@ -347,7 +347,7 @@ async fn get_following_returns_accepted_targets() { .await .unwrap(); - let actors = crate::social::get_following::execute(&query_deps, follower) + let actors = application::social::get_following::execute(&query_deps, follower) .await .unwrap(); @@ -393,7 +393,7 @@ async fn returns_accepted_followers() { .await .unwrap(); - let followers = crate::social::get_followers::execute(&query_deps, owner_id) + let followers = application::social::get_followers::execute(&query_deps, owner_id) .await .unwrap(); assert_eq!(followers.len(), 1); @@ -427,7 +427,7 @@ async fn returns_only_pending_followers() { .await .unwrap(); - let pending = crate::social::get_pending_followers::execute(&query_deps, owner_id) + let pending = application::social::get_pending_followers::execute(&query_deps, owner_id) .await .unwrap(); assert_eq!(pending.len(), 1); @@ -580,10 +580,10 @@ async fn get_pending_following_returns_unaccepted_targets_and_get_following_does .unwrap(); // deliberately NOT accepted - let pending = crate::social::get_pending_following::execute(&query_deps, follower) + let pending = application::social::get_pending_following::execute(&query_deps, follower) .await .unwrap(); - let accepted = crate::social::get_following::execute(&query_deps, follower) + let accepted = application::social::get_following::execute(&query_deps, follower) .await .unwrap(); @@ -620,7 +620,7 @@ async fn count_pending_followers_drops_as_requests_are_accepted() { .unwrap(); } - let before = crate::social::count_pending_followers::execute(&query_deps, owner.value()) + let before = application::social::count_pending_followers::execute(&query_deps, owner.value()) .await .unwrap(); assert_eq!(before, 2); @@ -635,7 +635,7 @@ async fn count_pending_followers_drops_as_requests_are_accepted() { .await .unwrap(); - let after = crate::social::count_pending_followers::execute(&query_deps, owner.value()) + let after = application::social::count_pending_followers::execute(&query_deps, owner.value()) .await .unwrap(); assert_eq!( @@ -666,10 +666,13 @@ async fn get_relation_use_case_reports_direction_asymmetrically() { .await .unwrap(); - let rel = - crate::social::get_relation::execute(&query_deps, viewer, SocialIdentity::Local(target)) - .await - .unwrap(); + let rel = application::social::get_relation::execute( + &query_deps, + viewer, + SocialIdentity::Local(target), + ) + .await + .unwrap(); assert_eq!( rel.following, diff --git a/crates/application/src/social/tests/local_service.rs b/crates/application/tests/social/local_service_test.rs similarity index 99% rename from crates/application/src/social/tests/local_service.rs rename to crates/application/tests/social/local_service_test.rs index cbe2b3ad..c2e9e7c2 100644 --- a/crates/application/src/social/tests/local_service.rs +++ b/crates/application/tests/social/local_service_test.rs @@ -15,7 +15,7 @@ use domain::{ }; use uuid::Uuid; -use crate::social::local_service::LocalSocialService; +use application::social::local_service::LocalSocialService; // ── Fakes ──────────────────────────────────────────────────────────────────── // diff --git a/crates/application/src/test_support.rs b/crates/application/tests/support/commands.rs similarity index 61% rename from crates/application/src/test_support.rs rename to crates/application/tests/support/commands.rs index ab4862fb..9cf0d28b 100644 --- a/crates/application/src/test_support.rs +++ b/crates/application/tests/support/commands.rs @@ -1,38 +1,33 @@ //! Command builders for tests. Each builder returns a command with sensible //! defaults; tests override individual fields with struct-update syntax: //! `LogReviewCommand { rating: 6, ..log_review_command(user, movie) }`. -//! Moves to `tests/support/mod.rs` when application tests become integration tests. -use chrono::{NaiveDate, NaiveDateTime}; +use chrono::NaiveDate; use uuid::Uuid; use domain::models::{FileFormat, UserRole, WatchEventSource}; +use domain::testing::test_watched_at; -use crate::auth::commands::RegisterCommand; -use crate::auth::queries::LoginCommand; -use crate::diary::commands::{EditReviewCommand, LogReviewCommand, MovieInput, SyncPosterCommand}; -use crate::goals::commands::{CreateGoalCommand, UpdateGoalCommand}; -use crate::import::commands::{ +use application::auth::commands::RegisterCommand; +use application::auth::queries::LoginCommand; +use application::diary::commands::{ + EditReviewCommand, LogReviewCommand, MovieInput, SyncPosterCommand, +}; +use application::goals::commands::{CreateGoalCommand, UpdateGoalCommand}; +use application::import::commands::{ ApplyImportMappingCommand, ApplyImportProfileCommand, CreateImportSessionCommand, ExecuteImportCommand, }; -use crate::integrations::commands::{ +use application::integrations::commands::{ ConfirmWatchEventsCommand, DismissWatchEventsCommand, GenerateWebhookTokenCommand, WatchEventConfirmation, }; -use crate::users::commands::UpdateProfileCommand; -use crate::users::update_settings::UpdateUserSettingsCommand; -use crate::watchlist::commands::AddToWatchlistCommand; -use crate::wrapup::commands::RequestWrapUpCommand; +use application::users::commands::UpdateProfileCommand; +use application::users::update_settings::UpdateUserSettingsCommand; +use application::watchlist::commands::AddToWatchlistCommand; +use application::wrapup::commands::RequestWrapUpCommand; -fn watched_at() -> NaiveDateTime { - NaiveDate::from_ymd_opt(2024, 6, 15) - .unwrap() - .and_hms_opt(20, 0, 0) - .unwrap() -} - -pub(crate) fn movie_input_by_id(movie_id: Uuid) -> MovieInput { +pub fn movie_input_by_id(movie_id: Uuid) -> MovieInput { MovieInput { movie_id: Some(movie_id), external_metadata_id: None, @@ -42,7 +37,7 @@ pub(crate) fn movie_input_by_id(movie_id: Uuid) -> MovieInput { } } -pub(crate) fn movie_input_manual(title: &str, year: u16) -> MovieInput { +pub fn movie_input_manual(title: &str, year: u16) -> MovieInput { MovieInput { movie_id: None, external_metadata_id: None, @@ -52,19 +47,19 @@ pub(crate) fn movie_input_manual(title: &str, year: u16) -> MovieInput { } } -pub(crate) fn log_review_command(user_id: Uuid, movie_id: Uuid) -> LogReviewCommand { +pub fn log_review_command(user_id: Uuid, movie_id: Uuid) -> LogReviewCommand { LogReviewCommand { user_id, input: movie_input_by_id(movie_id), rating: 4, comment: None, - watched_at: watched_at(), + watched_at: test_watched_at(), watch_medium: None, spoilers: false, } } -pub(crate) fn log_review_command_manual(user_id: Uuid, title: &str, year: u16) -> LogReviewCommand { +pub fn log_review_command_manual(user_id: Uuid, title: &str, year: u16) -> LogReviewCommand { LogReviewCommand { input: movie_input_manual(title, year), ..log_review_command(user_id, Uuid::nil()) @@ -72,7 +67,7 @@ pub(crate) fn log_review_command_manual(user_id: Uuid, title: &str, year: u16) - } /// Edits only the rating; `review_id` and `requesting_user_id` are random. -pub(crate) fn edit_review_command(rating: u8) -> EditReviewCommand { +pub fn edit_review_command(rating: u8) -> EditReviewCommand { EditReviewCommand { review_id: Uuid::new_v4(), requesting_user_id: Uuid::new_v4(), @@ -84,14 +79,11 @@ pub(crate) fn edit_review_command(rating: u8) -> EditReviewCommand { } } -pub(crate) fn sync_poster_command(movie_id: Uuid) -> SyncPosterCommand { +pub fn sync_poster_command(movie_id: Uuid) -> SyncPosterCommand { SyncPosterCommand { movie_id } } -pub(crate) fn register_command( - email: impl Into, - username: impl Into, -) -> RegisterCommand { +pub fn register_command(email: impl Into, username: impl Into) -> RegisterCommand { RegisterCommand { email: email.into(), username: username.into(), @@ -100,14 +92,14 @@ pub(crate) fn register_command( } } -pub(crate) fn login_command(email: impl Into, password: impl Into) -> LoginCommand { +pub fn login_command(email: impl Into, password: impl Into) -> LoginCommand { LoginCommand { email: email.into(), password: password.into(), } } -pub(crate) fn create_goal_command(year: u16, target_count: u32) -> CreateGoalCommand { +pub fn create_goal_command(year: u16, target_count: u32) -> CreateGoalCommand { CreateGoalCommand { user_id: Uuid::nil(), year, @@ -115,7 +107,7 @@ pub(crate) fn create_goal_command(year: u16, target_count: u32) -> CreateGoalCom } } -pub(crate) fn update_goal_command(year: u16, target_count: u32) -> UpdateGoalCommand { +pub fn update_goal_command(year: u16, target_count: u32) -> UpdateGoalCommand { UpdateGoalCommand { user_id: Uuid::nil(), year, @@ -124,7 +116,7 @@ pub(crate) fn update_goal_command(year: u16, target_count: u32) -> UpdateGoalCom } /// Confirms indices `[0]`. -pub(crate) fn execute_import_command(user_id: Uuid, session_id: Uuid) -> ExecuteImportCommand { +pub fn execute_import_command(user_id: Uuid, session_id: Uuid) -> ExecuteImportCommand { ExecuteImportCommand { user_id, session_id, @@ -132,10 +124,7 @@ pub(crate) fn execute_import_command(user_id: Uuid, session_id: Uuid) -> Execute } } -pub(crate) fn create_import_session_command( - user_id: Uuid, - csv: &[u8], -) -> CreateImportSessionCommand { +pub fn create_import_session_command(user_id: Uuid, csv: &[u8]) -> CreateImportSessionCommand { CreateImportSessionCommand { user_id, bytes: csv.to_vec(), @@ -144,10 +133,7 @@ pub(crate) fn create_import_session_command( } /// No field mappings. -pub(crate) fn apply_import_mapping_command( - user_id: Uuid, - session_id: Uuid, -) -> ApplyImportMappingCommand { +pub fn apply_import_mapping_command(user_id: Uuid, session_id: Uuid) -> ApplyImportMappingCommand { ApplyImportMappingCommand { user_id, session_id, @@ -155,7 +141,7 @@ pub(crate) fn apply_import_mapping_command( } } -pub(crate) fn apply_import_profile_command( +pub fn apply_import_profile_command( user_id: Uuid, session_id: Uuid, profile_id: Uuid, @@ -168,7 +154,7 @@ pub(crate) fn apply_import_profile_command( } /// One confirmation, rating as given, no comment. -pub(crate) fn confirm_watch_events_command( +pub fn confirm_watch_events_command( user_id: Uuid, watch_event_id: Uuid, rating: u8, @@ -183,7 +169,7 @@ pub(crate) fn confirm_watch_events_command( } } -pub(crate) fn dismiss_watch_events_command( +pub fn dismiss_watch_events_command( user_id: Uuid, event_ids: Vec, ) -> DismissWatchEventsCommand { @@ -191,7 +177,7 @@ pub(crate) fn dismiss_watch_events_command( } /// Jellyfin provider, no label. -pub(crate) fn generate_webhook_token_command(user_id: Uuid) -> GenerateWebhookTokenCommand { +pub fn generate_webhook_token_command(user_id: Uuid) -> GenerateWebhookTokenCommand { GenerateWebhookTokenCommand { user_id, provider: WatchEventSource::Jellyfin, @@ -200,7 +186,7 @@ pub(crate) fn generate_webhook_token_command(user_id: Uuid) -> GenerateWebhookTo } /// Every field unset; override what the test cares about. -pub(crate) fn update_profile_command(user_id: Uuid) -> UpdateProfileCommand { +pub fn update_profile_command(user_id: Uuid) -> UpdateProfileCommand { UpdateProfileCommand { user_id, display_name: None, @@ -214,7 +200,7 @@ pub(crate) fn update_profile_command(user_id: Uuid) -> UpdateProfileCommand { } /// All federation toggles on. -pub(crate) fn update_user_settings_command(user_id: Uuid) -> UpdateUserSettingsCommand { +pub fn update_user_settings_command(user_id: Uuid) -> UpdateUserSettingsCommand { UpdateUserSettingsCommand { user_id, federate_goals: true, @@ -223,7 +209,7 @@ pub(crate) fn update_user_settings_command(user_id: Uuid) -> UpdateUserSettingsC } } -pub(crate) fn add_to_watchlist_command(user_id: Uuid, movie_id: Uuid) -> AddToWatchlistCommand { +pub fn add_to_watchlist_command(user_id: Uuid, movie_id: Uuid) -> AddToWatchlistCommand { AddToWatchlistCommand { user_id, input: movie_input_by_id(movie_id), @@ -231,7 +217,7 @@ pub(crate) fn add_to_watchlist_command(user_id: Uuid, movie_id: Uuid) -> AddToWa } /// Window is 1 Jan of `year` to 1 Jan of `year + 1`. -pub(crate) fn request_wrap_up_command(user_id: Option, year: i32) -> RequestWrapUpCommand { +pub fn request_wrap_up_command(user_id: Option, year: i32) -> RequestWrapUpCommand { RequestWrapUpCommand { user_id, start_date: NaiveDate::from_ymd_opt(year, 1, 1).unwrap(), diff --git a/crates/application/src/test_helpers.rs b/crates/application/tests/support/context.rs similarity index 98% rename from crates/application/src/test_helpers.rs rename to crates/application/tests/support/context.rs index a377538b..1bc9d162 100644 --- a/crates/application/src/test_helpers.rs +++ b/crates/application/tests/support/context.rs @@ -24,7 +24,7 @@ use domain::{ use async_trait::async_trait; use domain::errors::DomainError; -use crate::{config::AppConfig, diary::commands::LogReviewCommand, ports::ReviewLogger}; +use application::{config::AppConfig, diary::commands::LogReviewCommand, ports::ReviewLogger}; pub struct NoopReviewLogger; @@ -130,7 +130,7 @@ impl TestContextBuilder { refresh_ttl_seconds: 2_592_000, secure_cookies: false, cors_origins: String::new(), - wrapup: crate::config::WrapUpConfig { + wrapup: application::config::WrapUpConfig { font_path: None, logo_path: None, bg_dir: None, diff --git a/crates/application/tests/support/mod.rs b/crates/application/tests/support/mod.rs new file mode 100644 index 00000000..fd6d9819 --- /dev/null +++ b/crates/application/tests/support/mod.rs @@ -0,0 +1,10 @@ +//! Shared fakes and builders for the application integration tests. +//! Included via `mod support;` from each `tests/.rs`; not every +//! binary uses every helper. +#![allow(dead_code, unused_imports)] + +mod commands; +mod context; + +pub use commands::*; +pub use context::*; diff --git a/crates/application/tests/users.rs b/crates/application/tests/users.rs new file mode 100644 index 00000000..855ac1db --- /dev/null +++ b/crates/application/tests/users.rs @@ -0,0 +1,26 @@ +mod support; + +#[path = "users/authorize_admin_test.rs"] +mod authorize_admin_test; +#[path = "users/get_current_profile_test.rs"] +mod get_current_profile_test; +#[path = "users/get_federated_profile_stats_test.rs"] +mod get_federated_profile_stats_test; +#[path = "users/get_federated_profile_test.rs"] +mod get_federated_profile_test; +#[path = "users/get_local_profile_test.rs"] +mod get_local_profile_test; +#[path = "users/get_page_viewer_test.rs"] +mod get_page_viewer_test; +#[path = "users/get_profile_settings_test.rs"] +mod get_profile_settings_test; +#[path = "users/get_settings_test.rs"] +mod get_settings_test; +#[path = "users/resolve_username_to_id_test.rs"] +mod resolve_username_to_id_test; +#[path = "users/update_profile_fields_test.rs"] +mod update_profile_fields_test; +#[path = "users/update_profile_test.rs"] +mod update_profile_test; +#[path = "users/update_settings_test.rs"] +mod update_settings_test; diff --git a/crates/application/src/users/tests/authorize_admin.rs b/crates/application/tests/users/authorize_admin_test.rs similarity index 95% rename from crates/application/src/users/tests/authorize_admin.rs rename to crates/application/tests/users/authorize_admin_test.rs index ce2e6eda..8e13cee0 100644 --- a/crates/application/src/users/tests/authorize_admin.rs +++ b/crates/application/tests/users/authorize_admin_test.rs @@ -1,12 +1,12 @@ -use crate::test_support::register_command; +use crate::support::TestContextBuilder; +use crate::support::register_command; use std::sync::Arc; use domain::models::UserRole; use domain::testing::InMemoryStore; -use crate::{ +use application::{ auth::{commands::RegisterCommand, deps::RegisterDeps, register}, - test_helpers::TestContextBuilder, users::{authorize_admin, deps::AuthorizeAdminDeps}, }; diff --git a/crates/application/src/users/tests/get_current_profile.rs b/crates/application/tests/users/get_current_profile_test.rs similarity index 97% rename from crates/application/src/users/tests/get_current_profile.rs rename to crates/application/tests/users/get_current_profile_test.rs index 01f6faac..f88e9194 100644 --- a/crates/application/src/users/tests/get_current_profile.rs +++ b/crates/application/tests/users/get_current_profile_test.rs @@ -1,4 +1,5 @@ -use crate::test_support::register_command; +use crate::support::TestContextBuilder; +use crate::support::register_command; use std::sync::Arc; use domain::models::{ProfileField, User, UserProfile, UserRole}; @@ -7,9 +8,8 @@ use domain::testing::InMemoryStore; use domain::value_objects::{Email, PasswordHash, UserId, Username}; use uuid::Uuid; -use crate::{ +use application::{ auth::{deps::RegisterDeps, register}, - test_helpers::TestContextBuilder, users::{deps::GetCurrentProfileDeps, get_current_profile, queries::GetCurrentProfileQuery}, }; diff --git a/crates/application/src/users/tests/get_federated_profile_stats.rs b/crates/application/tests/users/get_federated_profile_stats_test.rs similarity index 80% rename from crates/application/src/users/tests/get_federated_profile_stats.rs rename to crates/application/tests/users/get_federated_profile_stats_test.rs index ff2d43fd..05939ab6 100644 --- a/crates/application/src/users/tests/get_federated_profile_stats.rs +++ b/crates/application/tests/users/get_federated_profile_stats_test.rs @@ -1,7 +1,7 @@ -use crate::test_helpers::TestContextBuilder; -use crate::users::deps::GetFederatedProfileStatsDeps; -use crate::users::get_federated_profile_stats; -use crate::users::queries::{GetUserProfileQuery, ProfileView}; +use crate::support::TestContextBuilder; +use application::users::deps::GetFederatedProfileStatsDeps; +use application::users::get_federated_profile_stats; +use application::users::queries::{GetUserProfileQuery, ProfileView}; #[tokio::test] async fn succeeds_for_a_user_id_with_no_local_row() { diff --git a/crates/application/src/users/tests/get_federated_profile.rs b/crates/application/tests/users/get_federated_profile_test.rs similarity index 96% rename from crates/application/src/users/tests/get_federated_profile.rs rename to crates/application/tests/users/get_federated_profile_test.rs index d754cf86..45390240 100644 --- a/crates/application/src/users/tests/get_federated_profile.rs +++ b/crates/application/tests/users/get_federated_profile_test.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use async_trait::async_trait; use domain::{errors::DomainError, models::FederatedProfile, ports::FederatedProfileQuery}; -use crate::users::deps::GetFederatedProfileDeps; -use crate::users::get_federated_profile; +use application::users::deps::GetFederatedProfileDeps; +use application::users::get_federated_profile; fn a_profile() -> FederatedProfile { FederatedProfile { diff --git a/crates/application/src/users/tests/get_local_profile.rs b/crates/application/tests/users/get_local_profile_test.rs similarity index 95% rename from crates/application/src/users/tests/get_local_profile.rs rename to crates/application/tests/users/get_local_profile_test.rs index 6892046f..338df9a1 100644 --- a/crates/application/src/users/tests/get_local_profile.rs +++ b/crates/application/tests/users/get_local_profile_test.rs @@ -1,15 +1,15 @@ -use crate::test_support::{register_command, update_profile_command}; +use crate::support::{register_command, update_profile_command}; use domain::errors::DomainError; use domain::value_objects::Email; -use crate::auth::deps::RegisterDeps; -use crate::auth::register; -use crate::test_helpers::TestContextBuilder; -use crate::users::commands::UpdateProfileCommand; -use crate::users::deps::{GetLocalProfileDeps, UpdateProfileDeps}; -use crate::users::get_local_profile; -use crate::users::queries::{GetUserProfileQuery, ProfileView}; -use crate::users::update_profile; +use crate::support::TestContextBuilder; +use application::auth::deps::RegisterDeps; +use application::auth::register; +use application::users::commands::UpdateProfileCommand; +use application::users::deps::{GetLocalProfileDeps, UpdateProfileDeps}; +use application::users::get_local_profile; +use application::users::queries::{GetUserProfileQuery, ProfileView}; +use application::users::update_profile; async fn setup_user(b: &TestContextBuilder, email: &str, username: &str) { let deps = RegisterDeps { diff --git a/crates/application/src/users/tests/get_page_viewer.rs b/crates/application/tests/users/get_page_viewer_test.rs similarity index 86% rename from crates/application/src/users/tests/get_page_viewer.rs rename to crates/application/tests/users/get_page_viewer_test.rs index 788f5d0e..318c9c78 100644 --- a/crates/application/src/users/tests/get_page_viewer.rs +++ b/crates/application/tests/users/get_page_viewer_test.rs @@ -1,11 +1,11 @@ -use crate::test_support::register_command; +use crate::support::register_command; use domain::value_objects::{Email, FollowTarget, SocialIdentity, UserId}; -use crate::auth::deps::RegisterDeps; -use crate::auth::register; -use crate::test_helpers::TestContextBuilder; -use crate::users::deps::GetPageViewerDeps; -use crate::users::get_page_viewer; +use crate::support::TestContextBuilder; +use application::auth::deps::RegisterDeps; +use application::auth::register; +use application::users::deps::GetPageViewerDeps; +use application::users::get_page_viewer; async fn setup_user(b: &TestContextBuilder, email: &str, username: &str) -> uuid::Uuid { let deps = RegisterDeps { diff --git a/crates/application/src/users/tests/get_profile_settings.rs b/crates/application/tests/users/get_profile_settings_test.rs similarity index 84% rename from crates/application/src/users/tests/get_profile_settings.rs rename to crates/application/tests/users/get_profile_settings_test.rs index defb2a06..d8ca2c49 100644 --- a/crates/application/src/users/tests/get_profile_settings.rs +++ b/crates/application/tests/users/get_profile_settings_test.rs @@ -1,12 +1,12 @@ -use crate::test_support::register_command; +use crate::support::register_command; use domain::models::ProfileField; use domain::value_objects::{Email, UserId}; -use crate::auth::deps::RegisterDeps; -use crate::auth::register; -use crate::test_helpers::TestContextBuilder; -use crate::users::deps::GetProfileSettingsDeps; -use crate::users::get_profile_settings; +use crate::support::TestContextBuilder; +use application::auth::deps::RegisterDeps; +use application::auth::register; +use application::users::deps::GetProfileSettingsDeps; +use application::users::get_profile_settings; #[tokio::test] async fn get_profile_settings_includes_profile_fields() { diff --git a/crates/application/src/users/tests/get_settings.rs b/crates/application/tests/users/get_settings_test.rs similarity index 79% rename from crates/application/src/users/tests/get_settings.rs rename to crates/application/tests/users/get_settings_test.rs index fd02f4f7..96fc273e 100644 --- a/crates/application/src/users/tests/get_settings.rs +++ b/crates/application/tests/users/get_settings_test.rs @@ -1,9 +1,7 @@ +use crate::support::TestContextBuilder; use uuid::Uuid; -use crate::{ - test_helpers::TestContextBuilder, - users::{deps::GetSettingsDeps, get_settings}, -}; +use application::users::{deps::GetSettingsDeps, get_settings}; #[tokio::test] async fn returns_default_settings() { diff --git a/crates/application/src/users/tests/resolve_username_to_id.rs b/crates/application/tests/users/resolve_username_to_id_test.rs similarity index 75% rename from crates/application/src/users/tests/resolve_username_to_id.rs rename to crates/application/tests/users/resolve_username_to_id_test.rs index 05fa48a5..cbf865ba 100644 --- a/crates/application/src/users/tests/resolve_username_to_id.rs +++ b/crates/application/tests/users/resolve_username_to_id_test.rs @@ -1,8 +1,8 @@ use domain::value_objects::Username; -use crate::test_helpers::TestContextBuilder; -use crate::users::deps::ResolveUsernameDeps; -use crate::users::resolve_username_to_id; +use crate::support::TestContextBuilder; +use application::users::deps::ResolveUsernameDeps; +use application::users::resolve_username_to_id; #[tokio::test] async fn resolve_username_to_id_returns_none_for_unknown() { diff --git a/crates/application/src/users/tests/update_profile_fields.rs b/crates/application/tests/users/update_profile_fields_test.rs similarity index 91% rename from crates/application/src/users/tests/update_profile_fields.rs rename to crates/application/tests/users/update_profile_fields_test.rs index 7cf15d8b..eb00c1fa 100644 --- a/crates/application/src/users/tests/update_profile_fields.rs +++ b/crates/application/tests/users/update_profile_fields_test.rs @@ -1,3 +1,4 @@ +use crate::support::TestContextBuilder; use std::sync::Arc; use domain::events::DomainEvent; @@ -5,11 +6,8 @@ use domain::models::ProfileField; use domain::testing::{InMemoryStore, NoopEventPublisher}; use uuid::Uuid; -use crate::{ - test_helpers::TestContextBuilder, - users::{ - commands::UpdateProfileFieldsCommand, deps::UpdateProfileFieldsDeps, update_profile_fields, - }, +use application::users::{ + commands::UpdateProfileFieldsCommand, deps::UpdateProfileFieldsDeps, update_profile_fields, }; #[tokio::test] diff --git a/crates/application/src/users/tests/update_profile.rs b/crates/application/tests/users/update_profile_test.rs similarity index 98% rename from crates/application/src/users/tests/update_profile.rs rename to crates/application/tests/users/update_profile_test.rs index f1e0de0c..14540b62 100644 --- a/crates/application/src/users/tests/update_profile.rs +++ b/crates/application/tests/users/update_profile_test.rs @@ -1,4 +1,5 @@ -use crate::test_support::{register_command, update_profile_command}; +use crate::support::TestContextBuilder; +use crate::support::{register_command, update_profile_command}; use std::sync::Arc; use domain::events::DomainEvent; @@ -6,9 +7,8 @@ use domain::ports::UserRepository; use domain::testing::{InMemoryStore, NoopEventPublisher}; use uuid::Uuid; -use crate::{ +use application::{ auth::{deps::RegisterDeps, register}, - test_helpers::TestContextBuilder, users::{commands::UpdateProfileCommand, deps::UpdateProfileDeps, update_profile}, }; diff --git a/crates/application/src/users/tests/update_settings.rs b/crates/application/tests/users/update_settings_test.rs similarity index 86% rename from crates/application/src/users/tests/update_settings.rs rename to crates/application/tests/users/update_settings_test.rs index 77d4bce5..cd4b51b4 100644 --- a/crates/application/src/users/tests/update_settings.rs +++ b/crates/application/tests/users/update_settings_test.rs @@ -1,16 +1,14 @@ -use crate::test_support::update_user_settings_command; +use crate::support::TestContextBuilder; +use crate::support::update_user_settings_command; use std::sync::Arc; use domain::testing::InMemoryStore; use uuid::Uuid; -use crate::{ - test_helpers::TestContextBuilder, - users::{ - deps::{GetSettingsDeps, UpdateSettingsDeps}, - get_settings, - update_settings::UpdateUserSettingsCommand, - }, +use application::users::{ + deps::{GetSettingsDeps, UpdateSettingsDeps}, + get_settings, + update_settings::UpdateUserSettingsCommand, }; #[tokio::test] @@ -20,7 +18,7 @@ async fn updates_federate_goals() { let user_settings = b.user_settings_repo.clone(); let uid = Uuid::nil(); - crate::users::update_settings::execute( + application::users::update_settings::execute( &UpdateSettingsDeps { user_settings: user_settings.clone(), }, @@ -47,7 +45,7 @@ async fn updates_federate_reviews() { let user_settings = b.user_settings_repo.clone(); let uid = Uuid::nil(); - crate::users::update_settings::execute( + application::users::update_settings::execute( &UpdateSettingsDeps { user_settings: user_settings.clone(), }, @@ -74,7 +72,7 @@ async fn updates_federate_watchlist() { let user_settings = b.user_settings_repo.clone(); let uid = Uuid::nil(); - crate::users::update_settings::execute( + application::users::update_settings::execute( &UpdateSettingsDeps { user_settings: user_settings.clone(), }, diff --git a/crates/application/tests/watchlist.rs b/crates/application/tests/watchlist.rs new file mode 100644 index 00000000..fdc78e7c --- /dev/null +++ b/crates/application/tests/watchlist.rs @@ -0,0 +1,12 @@ +mod support; + +#[path = "watchlist/add_test.rs"] +mod add_test; +#[path = "watchlist/get_test.rs"] +mod get_test; +#[path = "watchlist/get_watchlist_for_owner_test.rs"] +mod get_watchlist_for_owner_test; +#[path = "watchlist/is_on_test.rs"] +mod is_on_test; +#[path = "watchlist/remove_test.rs"] +mod remove_test; diff --git a/crates/application/src/watchlist/tests/add.rs b/crates/application/tests/watchlist/add_test.rs similarity index 87% rename from crates/application/src/watchlist/tests/add.rs rename to crates/application/tests/watchlist/add_test.rs index 4b664c79..20c3572c 100644 --- a/crates/application/src/watchlist/tests/add.rs +++ b/crates/application/tests/watchlist/add_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::{add_to_watchlist_command, movie_input_manual}; +use crate::support::{add_to_watchlist_command, movie_input_manual}; use domain::testing::test_movie_with_year; use std::sync::Arc; @@ -7,7 +7,7 @@ use domain::{ testing::{InMemoryStore, NoopEventPublisher}, }; -use crate::watchlist::{add, commands::AddToWatchlistCommand, deps::WatchlistAddDeps}; +use application::watchlist::{add, commands::AddToWatchlistCommand, deps::WatchlistAddDeps}; fn make_deps(movies: Arc, watchlist: Arc) -> WatchlistAddDeps { WatchlistAddDeps { @@ -20,7 +20,7 @@ fn make_deps(movies: Arc, watchlist: Arc) -> Watch } #[tokio::test] -async fn test_add_to_watchlist_resolves_and_saves() { +async fn adding_to_the_watchlist_resolves_the_movie_and_saves_the_entry() { let movies = InMemoryStore::new(); let watchlist = Arc::clone(&movies); @@ -38,7 +38,7 @@ async fn test_add_to_watchlist_resolves_and_saves() { } #[tokio::test] -async fn test_add_to_watchlist_already_present_is_idempotent() { +async fn adding_a_movie_already_on_the_watchlist_is_idempotent() { let movies = InMemoryStore::new(); let watchlist = Arc::clone(&movies); @@ -62,7 +62,7 @@ async fn test_add_to_watchlist_already_present_is_idempotent() { } #[tokio::test] -async fn test_add_to_watchlist_with_manual_movie() { +async fn adding_a_manual_movie_to_the_watchlist_creates_and_saves_it() { let movies = InMemoryStore::new(); let watchlist = Arc::clone(&movies); @@ -80,7 +80,7 @@ async fn test_add_to_watchlist_with_manual_movie() { } #[tokio::test] -async fn test_add_to_watchlist_movie_not_found_by_id() { +async fn adding_an_unknown_movie_id_to_the_watchlist_fails() { let movies = InMemoryStore::new(); let watchlist = Arc::clone(&movies); diff --git a/crates/application/src/watchlist/tests/get.rs b/crates/application/tests/watchlist/get_test.rs similarity index 79% rename from crates/application/src/watchlist/tests/get.rs rename to crates/application/tests/watchlist/get_test.rs index a77ba973..d1d621f6 100644 --- a/crates/application/src/watchlist/tests/get.rs +++ b/crates/application/tests/watchlist/get_test.rs @@ -1,7 +1,7 @@ use uuid::Uuid; -use crate::test_helpers::TestContextBuilder; -use crate::watchlist::{deps::GetWatchlistDeps, get, queries::GetWatchlistQuery}; +use crate::support::TestContextBuilder; +use application::watchlist::{deps::GetWatchlistDeps, get, queries::GetWatchlistQuery}; #[tokio::test] async fn returns_empty_page_for_new_user() { diff --git a/crates/application/src/watchlist/tests/get_watchlist_for_owner.rs b/crates/application/tests/watchlist/get_watchlist_for_owner_test.rs similarity index 92% rename from crates/application/src/watchlist/tests/get_watchlist_for_owner.rs rename to crates/application/tests/watchlist/get_watchlist_for_owner_test.rs index 2d13a9d4..c0d627ce 100644 --- a/crates/application/src/watchlist/tests/get_watchlist_for_owner.rs +++ b/crates/application/tests/watchlist/get_watchlist_for_owner_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::register_command; +use crate::support::register_command; use std::sync::Arc; use uuid::Uuid; @@ -6,11 +6,11 @@ use uuid::Uuid; use domain::testing::{InMemoryStore, PanicRemoteWatchlistRepository, PanicWatchlistRepository}; use domain::value_objects::Email; -use crate::auth::deps::RegisterDeps; -use crate::auth::register; -use crate::test_helpers::TestContextBuilder; -use crate::watchlist::deps::GetWatchlistForOwnerDeps; -use crate::watchlist::get_watchlist_for_owner::{self, WatchlistView}; +use crate::support::TestContextBuilder; +use application::auth::deps::RegisterDeps; +use application::auth::register; +use application::watchlist::deps::GetWatchlistForOwnerDeps; +use application::watchlist::get_watchlist_for_owner::{self, WatchlistView}; async fn setup_user(b: &TestContextBuilder, email: &str, username: &str) { let deps = RegisterDeps { diff --git a/crates/application/src/watchlist/tests/is_on.rs b/crates/application/tests/watchlist/is_on_test.rs similarity index 90% rename from crates/application/src/watchlist/tests/is_on.rs rename to crates/application/tests/watchlist/is_on_test.rs index 9ca68ba3..2b59f127 100644 --- a/crates/application/src/watchlist/tests/is_on.rs +++ b/crates/application/tests/watchlist/is_on_test.rs @@ -6,8 +6,8 @@ use domain::testing::InMemoryStore; use domain::value_objects::{MovieId, UserId}; use uuid::Uuid; -use crate::test_helpers::TestContextBuilder; -use crate::watchlist::{deps::IsOnWatchlistDeps, is_on, queries::IsOnWatchlistQuery}; +use crate::support::TestContextBuilder; +use application::watchlist::{deps::IsOnWatchlistDeps, is_on, queries::IsOnWatchlistQuery}; #[tokio::test] async fn returns_true_when_present() { diff --git a/crates/application/src/watchlist/tests/remove.rs b/crates/application/tests/watchlist/remove_test.rs similarity index 96% rename from crates/application/src/watchlist/tests/remove.rs rename to crates/application/tests/watchlist/remove_test.rs index 256f629c..0616e298 100644 --- a/crates/application/src/watchlist/tests/remove.rs +++ b/crates/application/tests/watchlist/remove_test.rs @@ -7,8 +7,8 @@ use domain::testing::{InMemoryStore, NoopEventPublisher}; use domain::value_objects::{MovieId, UserId}; use uuid::Uuid; -use crate::test_helpers::TestContextBuilder; -use crate::watchlist::{ +use crate::support::TestContextBuilder; +use application::watchlist::{ commands::RemoveFromWatchlistCommand, deps::RemoveFromWatchlistDeps, remove, }; diff --git a/crates/application/tests/worker.rs b/crates/application/tests/worker.rs new file mode 100644 index 00000000..be788c10 --- /dev/null +++ b/crates/application/tests/worker.rs @@ -0,0 +1,4 @@ +mod support; + +#[path = "worker/worker_test.rs"] +mod worker_test; diff --git a/crates/application/src/tests/worker.rs b/crates/application/tests/worker/worker_test.rs similarity index 98% rename from crates/application/src/tests/worker.rs rename to crates/application/tests/worker/worker_test.rs index 01729a65..56324c71 100644 --- a/crates/application/src/tests/worker.rs +++ b/crates/application/tests/worker/worker_test.rs @@ -1,4 +1,4 @@ -use super::*; +use application::worker::*; use async_trait::async_trait; use domain::testing::NoopAckHandle; use domain::value_objects::{ExternalMetadataId, MovieId}; @@ -6,6 +6,10 @@ use domain::{ errors::DomainError, events::{AckHandle, DomainEvent}, }; +use domain::{ + events::EventEnvelope, + ports::{EventConsumer, EventHandler}, +}; use futures::{stream, stream::BoxStream}; use std::sync::{Arc, Mutex}; diff --git a/crates/application/tests/wrapup.rs b/crates/application/tests/wrapup.rs new file mode 100644 index 00000000..8281caa3 --- /dev/null +++ b/crates/application/tests/wrapup.rs @@ -0,0 +1,16 @@ +mod support; + +#[path = "wrapup/compute_test.rs"] +mod compute_test; +#[path = "wrapup/delete_test.rs"] +mod delete_test; +#[path = "wrapup/generate_test.rs"] +mod generate_test; +#[path = "wrapup/get_ready_report_test.rs"] +mod get_ready_report_test; +#[path = "wrapup/get_wrapup_test.rs"] +mod get_wrapup_test; +#[path = "wrapup/handle_requested_test.rs"] +mod handle_requested_test; +#[path = "wrapup/list_wrapups_test.rs"] +mod list_wrapups_test; diff --git a/crates/application/src/wrapup/tests/compute.rs b/crates/application/tests/wrapup/compute_test.rs similarity index 93% rename from crates/application/src/wrapup/tests/compute.rs rename to crates/application/tests/wrapup/compute_test.rs index 1fdee7ec..42459dd3 100644 --- a/crates/application/src/wrapup/tests/compute.rs +++ b/crates/application/tests/wrapup/compute_test.rs @@ -4,7 +4,7 @@ use domain::models::wrapup::{DateRange, WrapUpScope}; use domain::testing::InMemoryWrapUpStatsQuery; use uuid::Uuid; -use crate::wrapup::queries::ComputeWrapUpQuery; +use application::wrapup::queries::ComputeWrapUpQuery; fn make_row(title: &str, rating: u8, watched_at: &str) -> WrapUpMovieRow { WrapUpMovieRow { @@ -44,7 +44,7 @@ async fn empty_report() { let stats = InMemoryWrapUpStatsQuery::new(); let user_id = Uuid::new_v4(); - let report = super::execute( + let report = application::wrapup::compute::execute( stats, ComputeWrapUpQuery { scope: WrapUpScope::User(user_id), @@ -74,7 +74,7 @@ async fn basic_stats() { let stats = InMemoryWrapUpStatsQuery::with_rows(vec![r1, r2]); - let report = super::execute( + let report = application::wrapup::compute::execute( stats, ComputeWrapUpQuery { scope: WrapUpScope::User(user_id), @@ -108,7 +108,7 @@ async fn rewatch_detection() { let stats = InMemoryWrapUpStatsQuery::with_rows(vec![r1, r2]); - let report = super::execute( + let report = application::wrapup::compute::execute( stats, ComputeWrapUpQuery { scope: WrapUpScope::User(user_id), @@ -139,7 +139,7 @@ async fn global_scope() { let stats = InMemoryWrapUpStatsQuery::with_rows(vec![r1, r2]); - let report = super::execute( + let report = application::wrapup::compute::execute( stats, ComputeWrapUpQuery { scope: WrapUpScope::Global, diff --git a/crates/application/src/wrapup/tests/delete.rs b/crates/application/tests/wrapup/delete_test.rs similarity index 93% rename from crates/application/src/wrapup/tests/delete.rs rename to crates/application/tests/wrapup/delete_test.rs index 2cbeb1df..08cb7a7b 100644 --- a/crates/application/src/wrapup/tests/delete.rs +++ b/crates/application/tests/wrapup/delete_test.rs @@ -3,8 +3,8 @@ use domain::models::wrapup::{WrapUpRecord, WrapUpStatus}; use domain::testing::InMemoryWrapUpRepository; use domain::value_objects::WrapUpId; -use crate::wrapup::delete; -use crate::wrapup::deps::DeleteWrapUpDeps; +use application::wrapup::delete; +use application::wrapup::deps::DeleteWrapUpDeps; #[tokio::test] async fn deletes_existing_wrapup() { diff --git a/crates/application/src/wrapup/tests/generate.rs b/crates/application/tests/wrapup/generate_test.rs similarity index 95% rename from crates/application/src/wrapup/tests/generate.rs rename to crates/application/tests/wrapup/generate_test.rs index fceec0bf..0d0657c6 100644 --- a/crates/application/src/wrapup/tests/generate.rs +++ b/crates/application/tests/wrapup/generate_test.rs @@ -1,4 +1,4 @@ -use crate::test_support::request_wrap_up_command; +use crate::support::request_wrap_up_command; use chrono::NaiveDate; use domain::events::DomainEvent; use domain::models::wrapup::{WrapUpRecord, WrapUpStatus}; @@ -8,8 +8,8 @@ use uuid::Uuid; use std::sync::Arc; -use crate::wrapup::deps::GenerateWrapUpDeps; -use crate::wrapup::{commands::RequestWrapUpCommand, generate}; +use application::wrapup::deps::GenerateWrapUpDeps; +use application::wrapup::{commands::RequestWrapUpCommand, generate}; fn deps( repo: &Arc, diff --git a/crates/application/src/wrapup/tests/get_ready_report.rs b/crates/application/tests/wrapup/get_ready_report_test.rs similarity index 97% rename from crates/application/src/wrapup/tests/get_ready_report.rs rename to crates/application/tests/wrapup/get_ready_report_test.rs index 5fc46c62..e8dcef7f 100644 --- a/crates/application/src/wrapup/tests/get_ready_report.rs +++ b/crates/application/tests/wrapup/get_ready_report_test.rs @@ -8,8 +8,8 @@ use domain::services::wrapup_analyzer; use domain::testing::InMemoryWrapUpRepository; use domain::value_objects::WrapUpId; -use crate::wrapup::deps::GetReadyReportDeps; -use crate::wrapup::get_ready_report; +use application::wrapup::deps::GetReadyReportDeps; +use application::wrapup::get_ready_report; fn year_range(year: i32) -> DateRange { DateRange::new( diff --git a/crates/application/src/wrapup/tests/get_wrapup.rs b/crates/application/tests/wrapup/get_wrapup_test.rs similarity index 93% rename from crates/application/src/wrapup/tests/get_wrapup.rs rename to crates/application/tests/wrapup/get_wrapup_test.rs index 9792d7ff..3a2f85a1 100644 --- a/crates/application/src/wrapup/tests/get_wrapup.rs +++ b/crates/application/tests/wrapup/get_wrapup_test.rs @@ -3,8 +3,8 @@ use domain::models::wrapup::{WrapUpRecord, WrapUpStatus}; use domain::testing::InMemoryWrapUpRepository; use domain::value_objects::WrapUpId; -use crate::wrapup::deps::GetWrapUpDeps; -use crate::wrapup::get_wrapup; +use application::wrapup::deps::GetWrapUpDeps; +use application::wrapup::get_wrapup; #[tokio::test] async fn returns_record_when_exists() { diff --git a/crates/application/src/wrapup/tests/handle_requested.rs b/crates/application/tests/wrapup/handle_requested_test.rs similarity index 98% rename from crates/application/src/wrapup/tests/handle_requested.rs rename to crates/application/tests/wrapup/handle_requested_test.rs index e436b96e..c7fb26ce 100644 --- a/crates/application/src/wrapup/tests/handle_requested.rs +++ b/crates/application/tests/wrapup/handle_requested_test.rs @@ -4,7 +4,7 @@ use domain::ports::WrapUpRepository; use domain::testing::{InMemoryWrapUpRepository, InMemoryWrapUpStatsQuery, NoopEventPublisher}; use domain::value_objects::WrapUpId; -use crate::wrapup::{deps::HandleWrapUpRequestedDeps, handle_requested}; +use application::wrapup::{deps::HandleWrapUpRequestedDeps, handle_requested}; #[tokio::test] async fn skips_if_already_ready() { diff --git a/crates/application/src/wrapup/tests/list_wrapups.rs b/crates/application/tests/wrapup/list_wrapups_test.rs similarity index 93% rename from crates/application/src/wrapup/tests/list_wrapups.rs rename to crates/application/tests/wrapup/list_wrapups_test.rs index da71dd39..ee4c50a8 100644 --- a/crates/application/src/wrapup/tests/list_wrapups.rs +++ b/crates/application/tests/wrapup/list_wrapups_test.rs @@ -4,8 +4,8 @@ use domain::testing::InMemoryWrapUpRepository; use domain::value_objects::WrapUpId; use uuid::Uuid; -use crate::wrapup::deps::ListWrapUpsDeps; -use crate::wrapup::list_wrapups::{self, ListWrapUpsQuery}; +use application::wrapup::deps::ListWrapUpsDeps; +use application::wrapup::list_wrapups::{self, ListWrapUpsQuery}; fn make_record(user_id: Option) -> WrapUpRecord { WrapUpRecord {