fmt
Some checks failed
CI / Check / Test (push) Has been cancelled

This commit is contained in:
2026-06-10 03:24:17 +02:00
parent deae83cfd1
commit 6e21ec115d
6 changed files with 38 additions and 9 deletions

View File

@@ -61,5 +61,8 @@ async fn test_register_short_password_fails() {
) )
.await; .await;
let err = result.unwrap_err().to_string(); let err = result.unwrap_err().to_string();
assert!(err.contains("8 characters"), "expected password length error, got: {err}"); assert!(
err.contains("8 characters"),
"expected password length error, got: {err}"
);
} }

View File

@@ -1,4 +1,6 @@
use domain::{errors::DomainError, events::DomainEvent, models::UserProfile, value_objects::UserId}; use domain::{
errors::DomainError, events::DomainEvent, models::UserProfile, value_objects::UserId,
};
use crate::{context::AppContext, users::commands::UpdateProfileFieldsCommand}; use crate::{context::AppContext, users::commands::UpdateProfileFieldsCommand};

View File

@@ -13,7 +13,11 @@ pub async fn execute(
.wrapup_stats .wrapup_stats
.get_reviews_with_profiles(&query.scope, &query.date_range) .get_reviews_with_profiles(&query.scope, &query.date_range)
.await?; .await?;
Ok(wrapup_analyzer::build_report(query.scope, query.date_range, &rows)) Ok(wrapup_analyzer::build_report(
query.scope,
query.date_range,
&rows,
))
} }
#[cfg(test)] #[cfg(test)]

View File

@@ -236,7 +236,10 @@ fn movie_is_manual_match_different_director_fails() {
#[test] #[test]
fn profile_fields_validates_max_count() { fn profile_fields_validates_max_count() {
let fields: Vec<ProfileField> = (0..5) let fields: Vec<ProfileField> = (0..5)
.map(|i| ProfileField { name: format!("f{i}"), value: format!("v{i}") }) .map(|i| ProfileField {
name: format!("f{i}"),
value: format!("v{i}"),
})
.collect(); .collect();
assert!(UserProfile::validate_custom_fields(&fields).is_err()); assert!(UserProfile::validate_custom_fields(&fields).is_err());
} }
@@ -244,7 +247,10 @@ fn profile_fields_validates_max_count() {
#[test] #[test]
fn profile_fields_allows_four() { fn profile_fields_allows_four() {
let fields: Vec<ProfileField> = (0..4) let fields: Vec<ProfileField> = (0..4)
.map(|i| ProfileField { name: format!("f{i}"), value: format!("v{i}") }) .map(|i| ProfileField {
name: format!("f{i}"),
value: format!("v{i}"),
})
.collect(); .collect();
assert!(UserProfile::validate_custom_fields(&fields).is_ok()); assert!(UserProfile::validate_custom_fields(&fields).is_ok());
} }

View File

@@ -35,7 +35,9 @@ pub struct UserProfile {
impl UserProfile { impl UserProfile {
pub const MAX_CUSTOM_FIELDS: usize = 4; pub const MAX_CUSTOM_FIELDS: usize = 4;
pub fn validate_custom_fields(fields: &[ProfileField]) -> Result<(), crate::errors::DomainError> { pub fn validate_custom_fields(
fields: &[ProfileField],
) -> Result<(), crate::errors::DomainError> {
if fields.len() > Self::MAX_CUSTOM_FIELDS { if fields.len() > Self::MAX_CUSTOM_FIELDS {
Err(crate::errors::DomainError::ValidationError( Err(crate::errors::DomainError::ValidationError(
"Maximum 4 profile fields allowed".into(), "Maximum 4 profile fields allowed".into(),

View File

@@ -63,7 +63,11 @@ fn avg_rating_is_correct() {
#[test] #[test]
fn rating_distribution_counts_correctly() { fn rating_distribution_counts_correctly() {
let rows = vec![row("A", 5, "2024-01"), row("B", 5, "2024-02"), row("C", 3, "2024-03")]; let rows = vec![
row("A", 5, "2024-01"),
row("B", 5, "2024-02"),
row("C", 3, "2024-03"),
];
let report = build_report(WrapUpScope::Global, range(), &rows); let report = build_report(WrapUpScope::Global, range(), &rows);
assert_eq!(report.rating_distribution[4], 2); assert_eq!(report.rating_distribution[4], 2);
assert_eq!(report.rating_distribution[2], 1); assert_eq!(report.rating_distribution[2], 1);
@@ -71,9 +75,17 @@ fn rating_distribution_counts_correctly() {
#[test] #[test]
fn movies_per_month_sorted_chronologically() { fn movies_per_month_sorted_chronologically() {
let rows = vec![row("A", 3, "2024-03"), row("B", 3, "2024-01"), row("C", 3, "2024-02")]; let rows = vec![
row("A", 3, "2024-03"),
row("B", 3, "2024-01"),
row("C", 3, "2024-02"),
];
let report = build_report(WrapUpScope::Global, range(), &rows); let report = build_report(WrapUpScope::Global, range(), &rows);
let yms: Vec<&str> = report.movies_per_month.iter().map(|m| m.year_month.as_str()).collect(); let yms: Vec<&str> = report
.movies_per_month
.iter()
.map(|m| m.year_month.as_str())
.collect();
assert_eq!(yms, ["2024-01", "2024-02", "2024-03"]); assert_eq!(yms, ["2024-01", "2024-02", "2024-03"]);
} }