refactor/tighten-architecture #26

Merged
GKaszewski merged 104 commits from refactor/tighten-architecture into master 2026-10-26 09:36:27 +00:00
175 changed files with 541 additions and 695 deletions
Showing only changes of commit 8526b77f18 - Show all commits

View File

@@ -52,7 +52,3 @@ pub async fn execute(deps: &LoginDeps, query: LoginCommand) -> Result<LoginResul
role: user.role().clone(),
})
}
#[cfg(test)]
#[path = "tests/login.rs"]
mod tests;

View File

@@ -5,7 +5,3 @@ use crate::auth::deps::LogoutDeps;
pub async fn execute(deps: &LogoutDeps, refresh_token: &str) -> Result<(), DomainError> {
deps.refresh_session.revoke(refresh_token).await
}
#[cfg(test)]
#[path = "tests/logout.rs"]
mod tests;

View File

@@ -50,7 +50,3 @@ pub async fn execute(
expires_at: generated.expires_at,
})
}
#[cfg(test)]
#[path = "tests/refresh.rs"]
mod tests;

View File

@@ -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;

View File

@@ -44,7 +44,3 @@ pub async fn execute(
)
.await
}
#[cfg(test)]
#[path = "tests/register_and_login.rs"]
mod tests;

View File

@@ -52,7 +52,3 @@ pub async fn execute(deps: &DeleteReviewDeps, cmd: DeleteReviewCommand) -> Resul
Ok(())
}
#[cfg(test)]
#[path = "tests/delete_review.rs"]
mod tests;

View File

@@ -55,7 +55,3 @@ pub async fn execute(deps: &EditReviewDeps, cmd: EditReviewCommand) -> Result<()
Ok(())
}
#[cfg(test)]
#[path = "tests/edit_review.rs"]
mod tests;

View File

@@ -60,7 +60,3 @@ async fn build_following_filter(
remote_actor_urls: remote_urls,
})
}
#[cfg(test)]
#[path = "tests/get_activity_feed.rs"]
mod tests;

View File

@@ -29,7 +29,3 @@ pub async fn execute(
deps.diary.query_diary(&filter).await
}
#[cfg(test)]
#[path = "tests/get_diary.rs"]
mod tests;

View File

@@ -42,7 +42,3 @@ pub async fn execute(
profile,
})
}
#[cfg(test)]
#[path = "tests/get_movie_social_page.rs"]
mod tests;

View File

@@ -22,7 +22,3 @@ pub async fn execute(
Ok((history, trend))
}
#[cfg(test)]
#[path = "tests/get_review_history.rs"]
mod tests;

View File

@@ -52,7 +52,3 @@ pub async fn execute(
entries: page.items,
})
}
#[cfg(test)]
#[path = "tests/get_user_feed.rs"]
mod tests;

View File

@@ -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;

View File

@@ -179,7 +179,3 @@ impl ResolutionStrategy for ManualMovieStrategy {
}
}
}
#[cfg(test)]
#[path = "tests/movie_resolver.rs"]
mod tests;

View File

@@ -110,7 +110,3 @@ impl ReviewLogger for DefaultReviewLogger {
self.event_publisher.publish(&review_event).await
}
}
#[cfg(test)]
#[path = "tests/review_logger.rs"]
mod tests;

View File

@@ -47,7 +47,3 @@ pub async fn execute(
current_count,
})
}
#[cfg(test)]
#[path = "tests/create.rs"]
mod tests;

View File

@@ -23,7 +23,3 @@ pub async fn execute(deps: &GoalCommandDeps, cmd: DeleteGoalCommand) -> Result<(
Ok(())
}
#[cfg(test)]
#[path = "tests/delete.rs"]
mod tests;

View File

@@ -25,7 +25,3 @@ pub async fn execute(
current_count,
}))
}
#[cfg(test)]
#[path = "tests/get.rs"]
mod tests;

View File

@@ -20,7 +20,3 @@ pub async fn execute(
Ok(result)
}
#[cfg(test)]
#[path = "tests/list.rs"]
mod tests;

View File

@@ -35,7 +35,3 @@ pub async fn execute(
current_count,
})
}
#[cfg(test)]
#[path = "tests/update.rs"]
mod tests;

View File

@@ -87,7 +87,3 @@ async fn mark_duplicates(
Ok(())
}
#[cfg(test)]
#[path = "tests/apply_mapping.rs"]
mod tests;

View File

@@ -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;

View File

@@ -58,7 +58,3 @@ pub async fn execute(
)
.await
}
#[cfg(test)]
#[path = "tests/apply_profile_and_map.rs"]
mod tests;

View File

@@ -5,7 +5,3 @@ use domain::{errors::DomainError, ports::ImportSessionRepository};
pub async fn execute(import_session: Arc<dyn ImportSessionRepository>) -> Result<u64, DomainError> {
import_session.delete_expired().await
}
#[cfg(test)]
#[path = "tests/cleanup.rs"]
mod tests;

View File

@@ -41,7 +41,3 @@ pub async fn execute(
sample_rows,
})
}
#[cfg(test)]
#[path = "tests/create_session.rs"]
mod tests;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -33,7 +33,3 @@ pub async fn execute(
sample_rows,
})
}
#[cfg(test)]
#[path = "tests/get_mapping_stage.rs"]
mod tests;

View File

@@ -37,7 +37,3 @@ pub async fn execute(
Ok(PreviewStage::Ready(PreviewRows { columns, rows }))
}
#[cfg(test)]
#[path = "tests/get_preview_stage.rs"]
mod tests;

View File

@@ -37,7 +37,3 @@ pub async fn execute(
row_count,
})
}
#[cfg(test)]
#[path = "tests/get_session_state.rs"]
mod tests;

View File

@@ -7,7 +7,3 @@ pub async fn execute(
) -> Result<Vec<ImportProfile>, DomainError> {
deps.import_profile.list_for_user(user_id).await
}
#[cfg(test)]
#[path = "tests/list_profiles.rs"]
mod tests;

View File

@@ -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;

View File

@@ -18,7 +18,3 @@ pub async fn execute<Tz: TimeZone + Sync>(
&rows, tz,
))
}
#[cfg(test)]
#[path = "tests/get.rs"]
mod tests;

View File

@@ -9,7 +9,3 @@ pub async fn execute(watch_event_command: Arc<dyn WatchEventCommand>) -> Result<
.delete_non_pending_older_than(cutoff)
.await
}
#[cfg(test)]
#[path = "tests/cleanup.rs"]
mod tests;

View File

@@ -67,7 +67,3 @@ pub async fn execute(
Ok(confirmed)
}
#[cfg(test)]
#[path = "tests/confirm.rs"]
mod tests;

View File

@@ -41,7 +41,3 @@ pub async fn execute(
Ok(count as u32)
}
#[cfg(test)]
#[path = "tests/dismiss.rs"]
mod tests;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -62,7 +62,3 @@ pub async fn execute(
Ok(())
}
#[cfg(test)]
#[path = "tests/ingest.rs"]
mod tests;

View File

@@ -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;

View File

@@ -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;

View File

@@ -76,7 +76,3 @@ fn extract_persons(cast: &[CastMember], crew: &[CrewMember]) -> Vec<Person> {
seen.into_values().collect()
}
#[cfg(test)]
#[path = "tests/enrich_movie.rs"]
mod tests;

View File

@@ -76,7 +76,3 @@ pub async fn execute(
}
}))
}
#[cfg(test)]
#[path = "tests/get_movie_profile.rs"]
mod tests;

View File

@@ -19,7 +19,3 @@ pub async fn execute(
};
deps.movie.list_movies(&page, &filter).await
}
#[cfg(test)]
#[path = "tests/get_movies.rs"]
mod tests;

View File

@@ -42,7 +42,3 @@ pub async fn fetch_if_stale(
Err(e) => Err(e),
}
}
#[cfg(test)]
#[path = "tests/request_enrichment.rs"]
mod tests;

View File

@@ -83,7 +83,3 @@ pub async fn execute(deps: &SyncPosterDeps, cmd: SyncPosterCommand) -> Result<()
Ok(())
}
#[cfg(test)]
#[path = "tests/sync_poster.rs"]
mod tests;

View File

@@ -21,7 +21,3 @@ pub async fn execute(deps: &GetPersonDeps, id: PersonId) -> Result<Option<Person
}
Ok(person)
}
#[cfg(test)]
#[path = "tests/get.rs"]
mod tests;

View File

@@ -19,7 +19,3 @@ pub async fn execute(deps: &GetPersonDeps, id: PersonId) -> Result<PersonCredits
}
Ok(credits)
}
#[cfg(test)]
#[path = "tests/get_credits.rs"]
mod tests;

View File

@@ -8,7 +8,3 @@ use crate::search::deps::SearchDeps;
pub async fn execute(deps: &SearchDeps, query: SearchQuery) -> Result<SearchResults, DomainError> {
deps.search_port.search(&query).await
}
#[cfg(test)]
#[path = "tests/execute.rs"]
mod tests;

View File

@@ -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;

View File

@@ -263,7 +263,3 @@ impl ResolvedFollow for LocalSocialService {
Ok(())
}
}
#[cfg(test)]
#[path = "tests/local_service.rs"]
mod tests;

View File

@@ -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;

View File

@@ -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"));
}
}

View File

@@ -50,7 +50,3 @@ pub async fn execute(
role: found.role().clone(),
})
}
#[cfg(test)]
#[path = "tests/get_current_profile.rs"]
mod tests;

View File

@@ -13,7 +13,3 @@ pub async fn execute(
None => Ok(None),
}
}
#[cfg(test)]
#[path = "tests/get_federated_profile.rs"]
mod tests;

View File

@@ -83,7 +83,3 @@ pub async fn execute(
}
}
}
#[cfg(test)]
#[path = "tests/get_federated_profile_stats.rs"]
mod tests;

View File

@@ -144,7 +144,3 @@ async fn load_social_counts(
.collect();
(following, followers, pending)
}
#[cfg(test)]
#[path = "tests/get_local_profile.rs"]
mod tests;

View File

@@ -38,7 +38,3 @@ pub async fn execute(deps: &GetPageViewerDeps, user_id: Uuid) -> Result<PageView
pending_follow_count,
})
}
#[cfg(test)]
#[path = "tests/get_page_viewer.rs"]
mod tests;

View File

@@ -45,7 +45,3 @@ pub async fn execute(
fields,
})
}
#[cfg(test)]
#[path = "tests/get_profile_settings.rs"]
mod tests;

View File

@@ -9,7 +9,3 @@ pub async fn execute(
let uid = UserId::from_uuid(user_id);
deps.user_settings.get(&uid).await
}
#[cfg(test)]
#[path = "tests/get_settings.rs"]
mod tests;

View File

@@ -17,7 +17,3 @@ pub async fn execute(
let user = deps.user.find_by_username(username).await?;
Ok(user.map(|u| u.id().clone()))
}
#[cfg(test)]
#[path = "tests/resolve_username_to_id.rs"]
mod tests;

View File

@@ -1,38 +0,0 @@
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"));
}

View File

@@ -1,17 +0,0 @@
use crate::test_helpers::TestContextBuilder;
use crate::users::get_users;
use crate::users::queries::GetUsersQuery;
#[tokio::test]
async fn returns_empty_when_no_users() {
let b = TestContextBuilder::new();
let user = b.user_repo.clone();
let social_query = b.social_query.clone();
let result = get_users::execute(user, social_query, GetUsersQuery)
.await
.unwrap();
assert!(result.users.is_empty());
assert!(result.remote_actors.is_empty());
}

View File

@@ -123,7 +123,3 @@ pub async fn execute(
Ok(())
}
#[cfg(test)]
#[path = "tests/update_profile.rs"]
mod tests;

View File

@@ -17,7 +17,3 @@ pub async fn execute(
.await?;
Ok(())
}
#[cfg(test)]
#[path = "tests/update_profile_fields.rs"]
mod tests;

View File

@@ -20,7 +20,3 @@ pub async fn execute(
settings.set_federate_watchlist(cmd.federate_watchlist);
deps.user_settings.save(&settings).await
}
#[cfg(test)]
#[path = "tests/update_settings.rs"]
mod tests;

View File

@@ -39,7 +39,3 @@ pub async fn execute(
Ok(())
}
#[cfg(test)]
#[path = "tests/add.rs"]
mod tests;

View File

@@ -18,7 +18,3 @@ pub async fn execute(
let page = PageParams::new(query.limit, query.offset)?;
deps.watchlist.get_for_user(&user_id, &page).await
}
#[cfg(test)]
#[path = "tests/get.rs"]
mod tests;

View File

@@ -52,7 +52,3 @@ pub async fn execute(
Ok(WatchlistView::Remote(entries))
}
}
#[cfg(test)]
#[path = "tests/get_watchlist_for_owner.rs"]
mod tests;

View File

@@ -14,7 +14,3 @@ pub async fn execute(
let movie_id = MovieId::from_uuid(query.movie_id);
deps.watchlist.contains(&user_id, &movie_id).await
}
#[cfg(test)]
#[path = "tests/is_on.rs"]
mod tests;

View File

@@ -22,7 +22,3 @@ pub async fn execute(
Ok(())
}
#[cfg(test)]
#[path = "tests/remove.rs"]
mod tests;

View File

@@ -84,7 +84,3 @@ async fn dispatch(handlers: Arc<Vec<Arc<dyn EventHandler>>>, envelope: EventEnve
tracing::error!("ack failed: {e}");
}
}
#[cfg(test)]
#[path = "tests/worker.rs"]
mod tests;

View File

@@ -19,7 +19,3 @@ pub async fn execute(
&rows,
))
}
#[cfg(test)]
#[path = "tests/compute.rs"]
mod tests;

View File

@@ -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;

View File

@@ -59,7 +59,3 @@ pub async fn execute(
Ok(id)
}
#[cfg(test)]
#[path = "tests/generate.rs"]
mod tests;

View File

@@ -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;

View File

@@ -10,7 +10,3 @@ pub async fn execute(
) -> Result<Option<WrapUpRecord>, DomainError> {
deps.wrapup_repo.get_by_id(&id).await
}
#[cfg(test)]
#[path = "tests/get_wrapup.rs"]
mod tests;

View File

@@ -52,7 +52,3 @@ pub async fn execute(
}
}
}
#[cfg(test)]
#[path = "tests/handle_requested.rs"]
mod tests;

View File

@@ -18,7 +18,3 @@ pub async fn execute(
None => deps.wrapup_repo.list_global().await,
}
}
#[cfg(test)]
#[path = "tests/list_wrapups.rs"]
mod tests;

View File

@@ -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;

View File

@@ -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(),

View File

@@ -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]

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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(),

View File

@@ -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;

View File

@@ -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);

View File

@@ -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<InMemoryStore>,

View File

@@ -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,

View File

@@ -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() {

View File

@@ -8,7 +8,7 @@ use domain::{
testing::{FakeDiaryQuery, InMemoryStore},
};
use crate::{
use application::{
diary::deps::GetMovieSocialPageDeps, diary::get_movie_social_page,
diary::queries::GetMovieSocialPageQuery,
};

View File

@@ -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,
};

View File

@@ -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 {

View File

@@ -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<InMemoryStore>,
reviews: &Arc<InMemoryStore>,
events: &Arc<NoopEventPublisher>,
) -> Arc<dyn crate::ports::ReviewLogger> {
) -> Arc<dyn application::ports::ReviewLogger> {
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();

View File

@@ -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,

View File

@@ -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<InMemoryStore>,

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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() {

Some files were not shown because too many files have changed in this diff Show More