fmt
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
use domain::{errors::DomainError, value_objects::{SocialActor, UserId}};
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
value_objects::{SocialActor, UserId},
|
||||
};
|
||||
|
||||
use super::{deps::SocialQueryDeps, queries::GetBlockedQuery};
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use domain::{errors::DomainError, value_objects::{SocialActor, UserId}};
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
value_objects::{SocialActor, UserId},
|
||||
};
|
||||
|
||||
use super::{deps::SocialQueryDeps, queries::GetFollowersQuery};
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use domain::{errors::DomainError, value_objects::{SocialActor, UserId}};
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
value_objects::{SocialActor, UserId},
|
||||
};
|
||||
|
||||
use super::{deps::SocialQueryDeps, queries::GetFollowingQuery};
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use domain::{errors::DomainError, value_objects::{SocialActor, UserId}};
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
value_objects::{SocialActor, UserId},
|
||||
};
|
||||
|
||||
use super::{deps::SocialQueryDeps, queries::GetPendingFollowersQuery};
|
||||
|
||||
|
||||
@@ -14,7 +14,11 @@ use crate::social::{
|
||||
follow,
|
||||
};
|
||||
|
||||
fn make_deps() -> (Arc<InMemorySocialRepository>, Arc<NoopEventPublisher>, SocialCommandDeps) {
|
||||
fn make_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
@@ -53,7 +57,9 @@ async fn accept_follow_emits_follow_accepted_event() {
|
||||
.unwrap();
|
||||
|
||||
let published = events.published();
|
||||
assert!(published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::FollowAccepted { .. })));
|
||||
assert!(
|
||||
published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::FollowAccepted { .. }))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,11 @@ use uuid::Uuid;
|
||||
|
||||
use crate::social::{block, commands::BlockCommand, deps::SocialCommandDeps};
|
||||
|
||||
fn make_deps() -> (Arc<InMemorySocialRepository>, Arc<NoopEventPublisher>, SocialCommandDeps) {
|
||||
fn make_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
@@ -35,7 +39,9 @@ async fn block_emits_actor_blocked_event() {
|
||||
.unwrap();
|
||||
|
||||
let published = events.published();
|
||||
assert!(published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::ActorBlocked { .. })));
|
||||
assert!(
|
||||
published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::ActorBlocked { .. }))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,11 @@ use uuid::Uuid;
|
||||
|
||||
use crate::social::{commands::FollowCommand, deps::SocialCommandDeps, follow};
|
||||
|
||||
fn make_deps() -> (Arc<InMemorySocialRepository>, Arc<NoopEventPublisher>, SocialCommandDeps) {
|
||||
fn make_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
@@ -35,9 +39,11 @@ async fn follow_emits_follow_requested_event() {
|
||||
.unwrap();
|
||||
|
||||
let published = events.published();
|
||||
assert!(published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::FollowRequested { .. })));
|
||||
assert!(
|
||||
published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::FollowRequested { .. }))
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -50,13 +50,8 @@ async fn returns_accepted_followers() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let followers = get_followers::execute(
|
||||
&query_deps,
|
||||
GetFollowersQuery {
|
||||
user_id: owner_id,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let followers = get_followers::execute(&query_deps, GetFollowersQuery { user_id: owner_id })
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(followers.len(), 1);
|
||||
}
|
||||
|
||||
@@ -39,13 +39,8 @@ async fn returns_only_pending_followers() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let pending = get_pending::execute(
|
||||
&query_deps,
|
||||
GetPendingFollowersQuery {
|
||||
user_id: owner_id,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let pending = get_pending::execute(&query_deps, GetPendingFollowersQuery { user_id: owner_id })
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(pending.len(), 1);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ use crate::social::{
|
||||
follow, reject,
|
||||
};
|
||||
|
||||
fn make_deps() -> (Arc<InMemorySocialRepository>, Arc<NoopEventPublisher>, SocialCommandDeps) {
|
||||
fn make_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
|
||||
@@ -14,7 +14,11 @@ use crate::social::{
|
||||
follow, remove_follower,
|
||||
};
|
||||
|
||||
fn make_deps() -> (Arc<InMemorySocialRepository>, Arc<NoopEventPublisher>, SocialCommandDeps) {
|
||||
fn make_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
@@ -62,7 +66,9 @@ async fn remove_follower_emits_follower_removed_event() {
|
||||
.unwrap();
|
||||
|
||||
let published = events.published();
|
||||
assert!(published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::FollowerRemoved { .. })));
|
||||
assert!(
|
||||
published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::FollowerRemoved { .. }))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,17 @@ use domain::{
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::social::{
|
||||
block,
|
||||
commands::{BlockCommand, UnblockCommand},
|
||||
deps::SocialCommandDeps,
|
||||
block, unblock,
|
||||
unblock,
|
||||
};
|
||||
|
||||
fn make_deps() -> (Arc<InMemorySocialRepository>, Arc<NoopEventPublisher>, SocialCommandDeps) {
|
||||
fn make_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
@@ -40,18 +45,14 @@ async fn unblock_emits_actor_unblocked_event() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
unblock::execute(
|
||||
&deps,
|
||||
UnblockCommand {
|
||||
blocker_id,
|
||||
target,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
unblock::execute(&deps, UnblockCommand { blocker_id, target })
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let published = events.published();
|
||||
assert!(published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::ActorUnblocked { .. })));
|
||||
assert!(
|
||||
published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::ActorUnblocked { .. }))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,11 @@ use crate::social::{
|
||||
follow, unfollow,
|
||||
};
|
||||
|
||||
fn make_deps() -> (Arc<InMemorySocialRepository>, Arc<NoopEventPublisher>, SocialCommandDeps) {
|
||||
fn make_deps() -> (
|
||||
Arc<InMemorySocialRepository>,
|
||||
Arc<NoopEventPublisher>,
|
||||
SocialCommandDeps,
|
||||
) {
|
||||
let social = InMemorySocialRepository::new();
|
||||
let events = NoopEventPublisher::new();
|
||||
let deps = SocialCommandDeps {
|
||||
@@ -51,7 +55,9 @@ async fn unfollow_emits_unfollowed_event() {
|
||||
.unwrap();
|
||||
|
||||
let published = events.published();
|
||||
assert!(published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::Unfollowed { .. })));
|
||||
assert!(
|
||||
published
|
||||
.iter()
|
||||
.any(|e| matches!(e, DomainEvent::Unfollowed { .. }))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@ use super::{commands::UnfollowCommand, deps::SocialCommandDeps};
|
||||
|
||||
pub async fn execute(deps: &SocialCommandDeps, cmd: UnfollowCommand) -> Result<(), DomainError> {
|
||||
let follower = UserId::from_uuid(cmd.follower_id);
|
||||
deps.social_command
|
||||
.unfollow(&follower, &cmd.target)
|
||||
.await?;
|
||||
deps.social_command.unfollow(&follower, &cmd.target).await?;
|
||||
deps.event_publisher
|
||||
.publish(&DomainEvent::Unfollowed {
|
||||
follower,
|
||||
|
||||
Reference in New Issue
Block a user