test: shared factories and command builders
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user