fix: update tests for expanded User profile signature

This commit is contained in:
2026-05-13 23:27:36 +02:00
parent 5edac78add
commit c420826474
3 changed files with 22 additions and 5 deletions

View File

@@ -10,13 +10,16 @@ fn make_user() -> User {
UserRole::Standard, UserRole::Standard,
None, None,
None, None,
None,
None,
vec![],
) )
} }
#[test] #[test]
fn update_profile_sets_fields() { fn update_profile_sets_fields() {
let mut user = make_user(); let mut user = make_user();
user.update_profile(Some("My bio".to_string()), Some("avatars/abc".to_string())); user.update_profile(Some("My bio".to_string()), Some("avatars/abc".to_string()), None, None);
assert_eq!(user.bio(), Some("My bio")); assert_eq!(user.bio(), Some("My bio"));
assert_eq!(user.avatar_path(), Some("avatars/abc")); assert_eq!(user.avatar_path(), Some("avatars/abc"));
} }
@@ -24,8 +27,8 @@ fn update_profile_sets_fields() {
#[test] #[test]
fn update_profile_clears_with_none() { fn update_profile_clears_with_none() {
let mut user = make_user(); let mut user = make_user();
user.update_profile(Some("bio".to_string()), Some("path".to_string())); user.update_profile(Some("bio".to_string()), Some("path".to_string()), None, None);
user.update_profile(None, None); user.update_profile(None, None, None, None);
assert_eq!(user.bio(), None); assert_eq!(user.bio(), None);
assert_eq!(user.avatar_path(), None); assert_eq!(user.avatar_path(), None);
} }

View File

@@ -215,11 +215,16 @@ impl UserRepository for Panic {
async fn list_with_stats(&self) -> Result<Vec<domain::models::UserSummary>, DomainError> { async fn list_with_stats(&self) -> Result<Vec<domain::models::UserSummary>, DomainError> {
panic!() panic!()
} }
async fn update_profile(&self, _: &UserId, _: Option<String>, _: Option<String>) -> Result<(), DomainError> { async fn update_profile(&self, _: &UserId, _: Option<String>, _: Option<String>, _: Option<String>, _: Option<String>) -> Result<(), DomainError> {
panic!() panic!()
} }
} }
#[async_trait::async_trait] #[async_trait::async_trait]
impl domain::ports::UserProfileFieldsRepository for Panic {
async fn get_fields(&self, _: &UserId) -> Result<Vec<domain::models::ProfileField>, DomainError> { panic!() }
async fn set_fields(&self, _: &UserId, _: Vec<domain::models::ProfileField>) -> Result<(), DomainError> { panic!() }
}
#[async_trait::async_trait]
impl EventPublisher for Panic { impl EventPublisher for Panic {
async fn publish(&self, _: &DomainEvent) -> Result<(), DomainError> { async fn publish(&self, _: &DomainEvent) -> Result<(), DomainError> {
panic!() panic!()
@@ -414,6 +419,7 @@ pub fn make_test_state(auth_service: Arc<dyn AuthService>) -> crate::state::AppS
import_profile_repository: Arc::clone(&repo) as _, import_profile_repository: Arc::clone(&repo) as _,
movie_profile_repository: Arc::clone(&repo) as _, movie_profile_repository: Arc::clone(&repo) as _,
watchlist_repository: Arc::clone(&repo) as _, watchlist_repository: Arc::clone(&repo) as _,
profile_fields_repository: Arc::clone(&repo) as _,
#[cfg(feature = "federation")] #[cfg(feature = "federation")]
remote_watchlist_repository: Arc::clone(&repo) as _, remote_watchlist_repository: Arc::clone(&repo) as _,
person_command: Arc::clone(&repo) as _, person_command: Arc::clone(&repo) as _,

View File

@@ -109,11 +109,18 @@ impl UserRepository for NobodyUserRepo {
async fn list_with_stats(&self) -> Result<Vec<domain::models::UserSummary>, DomainError> { async fn list_with_stats(&self) -> Result<Vec<domain::models::UserSummary>, DomainError> {
panic!() panic!()
} }
async fn update_profile(&self, _: &UserId, _: Option<String>, _: Option<String>) -> Result<(), DomainError> { async fn update_profile(&self, _: &UserId, _: Option<String>, _: Option<String>, _: Option<String>, _: Option<String>) -> Result<(), DomainError> {
Ok(()) Ok(())
} }
} }
struct PanicProfileFields;
#[async_trait]
impl domain::ports::UserProfileFieldsRepository for PanicProfileFields {
async fn get_fields(&self, _: &UserId) -> Result<Vec<domain::models::ProfileField>, DomainError> { Ok(vec![]) }
async fn set_fields(&self, _: &UserId, _: Vec<domain::models::ProfileField>) -> Result<(), DomainError> { panic!() }
}
struct PanicExporter; struct PanicExporter;
#[async_trait] #[async_trait]
impl domain::ports::DiaryExporter for PanicExporter { impl domain::ports::DiaryExporter for PanicExporter {
@@ -259,6 +266,7 @@ async fn test_app() -> Router {
import_profile_repository: Arc::new(PanicImportProfile), import_profile_repository: Arc::new(PanicImportProfile),
movie_profile_repository: Arc::new(PanicMovieProfile), movie_profile_repository: Arc::new(PanicMovieProfile),
watchlist_repository: Arc::new(PanicWatchlist), watchlist_repository: Arc::new(PanicWatchlist),
profile_fields_repository: Arc::new(PanicProfileFields),
#[cfg(feature = "federation")] #[cfg(feature = "federation")]
remote_watchlist_repository: Arc::new(PanicRemoteWatchlist), remote_watchlist_repository: Arc::new(PanicRemoteWatchlist),
person_command: Arc::new(PanicPersonCommand), person_command: Arc::new(PanicPersonCommand),