test: cascading in-memory store
This commit is contained in:
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use domain::{
|
||||
events::DomainEvent,
|
||||
testing::{InMemorySocialRepository, NoopEventPublisher},
|
||||
testing::{InMemoryStore, NoopEventPublisher},
|
||||
value_objects::{FollowStatus, FollowTarget, SocialIdentity, UserId},
|
||||
};
|
||||
use uuid::Uuid;
|
||||
@@ -14,11 +14,11 @@ use crate::social::{
|
||||
};
|
||||
|
||||
fn make_cmd_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<InMemoryStore>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let social = InMemoryStore::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
social_command: Arc::clone(&social) as _,
|
||||
@@ -359,7 +359,7 @@ async fn get_following_returns_accepted_targets() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn returns_accepted_followers() {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let social = InMemoryStore::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let cmd_deps = SocialCommandDeps {
|
||||
social_command: Arc::clone(&social) as _,
|
||||
@@ -403,7 +403,7 @@ async fn returns_accepted_followers() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn returns_only_pending_followers() {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let social = InMemoryStore::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let cmd_deps = SocialCommandDeps {
|
||||
social_command: Arc::clone(&social) as _,
|
||||
|
||||
@@ -7,7 +7,7 @@ use domain::{
|
||||
ports::{
|
||||
BlockQuery, FollowCommand, FollowGraphQuery, FollowQuery, SocialCommand, UserRepository,
|
||||
},
|
||||
testing::InMemoryUserRepository,
|
||||
testing::InMemoryStore,
|
||||
value_objects::{
|
||||
FollowRelation, FollowStatus, FollowTarget, InstanceIdentity, SocialActor, SocialIdentity,
|
||||
UserId,
|
||||
@@ -19,7 +19,7 @@ use crate::social::local_service::LocalSocialService;
|
||||
|
||||
// ── Fakes ────────────────────────────────────────────────────────────────────
|
||||
//
|
||||
// No fake exists anywhere for FollowCommand/FollowQuery. `InMemorySocialRepository`
|
||||
// No fake exists anywhere for FollowCommand/FollowQuery. `InMemoryStore`
|
||||
// (domain::testing) implements SocialCommand/FollowGraphQuery/BlockQuery — the same
|
||||
// level as LocalSocialService itself — so it cannot stand in as its dependency.
|
||||
// A single struct backs both ports, mirroring how one database table serves both
|
||||
@@ -246,7 +246,7 @@ fn instance() -> InstanceIdentity {
|
||||
InstanceIdentity::new("http://md.example")
|
||||
}
|
||||
|
||||
async fn register_user(repo: &Arc<InMemoryUserRepository>, username: &str) -> UserId {
|
||||
async fn register_user(repo: &Arc<InMemoryStore>, username: &str) -> UserId {
|
||||
let user = test_user(username);
|
||||
let id = user.id().clone();
|
||||
repo.save(&user).await.unwrap();
|
||||
@@ -254,7 +254,7 @@ async fn register_user(repo: &Arc<InMemoryUserRepository>, username: &str) -> Us
|
||||
}
|
||||
|
||||
fn service(
|
||||
user_repo: Arc<InMemoryUserRepository>,
|
||||
user_repo: Arc<InMemoryStore>,
|
||||
follow_store: &Arc<FollowFakeStore>,
|
||||
instance: InstanceIdentity,
|
||||
) -> LocalSocialService {
|
||||
@@ -270,7 +270,7 @@ fn service(
|
||||
|
||||
#[tokio::test]
|
||||
async fn follow_local_user_writes_both_sides() {
|
||||
let user_repo = InMemoryUserRepository::new();
|
||||
let user_repo = InMemoryStore::new();
|
||||
let bob_id = register_user(&user_repo, "bob").await;
|
||||
let alice_id = register_user(&user_repo, "alice").await;
|
||||
let follow_store = FollowFakeStore::new();
|
||||
@@ -302,7 +302,7 @@ async fn follow_local_user_writes_both_sides() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn follow_self_is_rejected() {
|
||||
let user_repo = InMemoryUserRepository::new();
|
||||
let user_repo = InMemoryStore::new();
|
||||
let alice_id = register_user(&user_repo, "alice").await;
|
||||
let follow_store = FollowFakeStore::new();
|
||||
let svc = service(user_repo, &follow_store, instance());
|
||||
@@ -335,7 +335,7 @@ async fn follow_self_is_rejected() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn follow_remote_target_errors_rather_than_silently_succeeding() {
|
||||
let user_repo = InMemoryUserRepository::new();
|
||||
let user_repo = InMemoryStore::new();
|
||||
let alice_id = register_user(&user_repo, "alice").await;
|
||||
let follow_store = FollowFakeStore::new();
|
||||
let svc = service(user_repo, &follow_store, instance());
|
||||
@@ -376,7 +376,7 @@ async fn reject_follow_updates_follower_status_but_removes_the_follow_row() {
|
||||
// the follow row outright. A test that only checked the follower row would
|
||||
// pass against a reject_follow "corrected" into accept_follow's symmetry —
|
||||
// the second assertion is the one that carries the weight.
|
||||
let user_repo = InMemoryUserRepository::new();
|
||||
let user_repo = InMemoryStore::new();
|
||||
let owner_id = register_user(&user_repo, "owner").await;
|
||||
let requester_id = register_user(&user_repo, "requester").await;
|
||||
let follow_store = FollowFakeStore::new();
|
||||
@@ -422,7 +422,7 @@ async fn reject_follow_updates_follower_status_but_removes_the_follow_row() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn block_errors_and_get_blocked_is_empty() {
|
||||
let user_repo = InMemoryUserRepository::new();
|
||||
let user_repo = InMemoryStore::new();
|
||||
let alice_id = register_user(&user_repo, "alice").await;
|
||||
let follow_store = FollowFakeStore::new();
|
||||
let svc = service(user_repo, &follow_store, instance());
|
||||
|
||||
Reference in New Issue
Block a user