test(application): fill unit test gaps — api_keys, profile, auth, thoughts, social
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 5m7s
test / unit (pull_request) Successful in 16m2s
test / integration (pull_request) Failing after 16m57s
Some checks failed
lint / lint (push) Has been cancelled
test / unit (push) Has been cancelled
test / integration (push) Has been cancelled
lint / lint (pull_request) Failing after 5m7s
test / unit (pull_request) Successful in 16m2s
test / integration (pull_request) Failing after 16m57s
This commit is contained in:
@@ -136,4 +136,37 @@ mod tests {
|
||||
assert_eq!(events.len(), 1);
|
||||
assert!(matches!(events[0], DomainEvent::UserUnblocked { .. }));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn block_user_saves_block_and_publishes_event() {
|
||||
let store = TestStore::default();
|
||||
let alice = user("alice");
|
||||
let bob = user("bob");
|
||||
block_user(&store, &store, &alice.id, &bob.id).await.unwrap();
|
||||
assert_eq!(store.blocks.lock().unwrap().len(), 1);
|
||||
let events = store.events.lock().unwrap();
|
||||
assert!(events.iter().any(|e| matches!(e, DomainEvent::UserBlocked { blocker_id, .. } if blocker_id == &alice.id)));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn cannot_block_self() {
|
||||
let store = TestStore::default();
|
||||
let alice = user("alice");
|
||||
let err = block_user(&store, &store, &alice.id, &alice.id).await.unwrap_err();
|
||||
assert!(matches!(err, DomainError::InvalidInput(_)));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn boost_and_unboost() {
|
||||
let store = TestStore::default();
|
||||
let alice = user("alice");
|
||||
let tid = ThoughtId::new();
|
||||
boost_thought(&store, &store, &alice.id, &tid).await.unwrap();
|
||||
assert_eq!(store.boosts.lock().unwrap().len(), 1);
|
||||
unboost_thought(&store, &store, &alice.id, &tid).await.unwrap();
|
||||
assert!(store.boosts.lock().unwrap().is_empty());
|
||||
let events = store.events.lock().unwrap();
|
||||
assert!(events.iter().any(|e| matches!(e, DomainEvent::BoostAdded { .. })));
|
||||
assert!(events.iter().any(|e| matches!(e, DomainEvent::BoostRemoved { .. })));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user