test: shared factories and command builders

This commit is contained in:
2026-10-25 22:08:17 +01:00
parent 2ac1d4e0cf
commit 51d92e08a7
58 changed files with 784 additions and 1344 deletions

View File

@@ -1,16 +1,16 @@
use domain::testing::test_user;
use std::sync::{Arc, Mutex};
use async_trait::async_trait;
use domain::{
errors::DomainError,
models::{User, UserRole},
ports::{
BlockQuery, FollowCommand, FollowGraphQuery, FollowQuery, SocialCommand, UserRepository,
},
testing::InMemoryUserRepository,
value_objects::{
Email, FollowRelation, FollowStatus, FollowTarget, InstanceIdentity, PasswordHash,
SocialActor, SocialIdentity, UserId, Username,
FollowRelation, FollowStatus, FollowTarget, InstanceIdentity, SocialActor, SocialIdentity,
UserId,
},
};
use uuid::Uuid;
@@ -247,12 +247,7 @@ fn instance() -> InstanceIdentity {
}
async fn register_user(repo: &Arc<InMemoryUserRepository>, username: &str) -> UserId {
let user = User::new(
Email::new(format!("{username}@example.com")).unwrap(),
Username::new(username.to_string()).unwrap(),
PasswordHash::new("hashed-password".to_string()).unwrap(),
UserRole::Standard,
);
let user = test_user(username);
let id = user.id().clone();
repo.save(&user).await.unwrap();
id