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:
@@ -119,4 +119,42 @@ mod tests {
|
||||
let err = delete_thought(&store, &NoOpEventPublisher, &out.thought.id, &bob.id).await.unwrap_err();
|
||||
assert!(matches!(err, DomainError::NotFound));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn edit_thought_changes_content_and_emits_event() {
|
||||
let store = TestStore::default();
|
||||
let alice = user();
|
||||
store.users.lock().unwrap().push(alice.clone());
|
||||
let out = create_thought(&store, &store, &store, input(alice.id.clone())).await.unwrap();
|
||||
let tid = out.thought.id.clone();
|
||||
|
||||
edit_thought(&store, &store, &tid, &alice.id, "updated".to_string()).await.unwrap();
|
||||
|
||||
let saved = store.thoughts.lock().unwrap().iter().find(|t| t.id == tid).unwrap().clone();
|
||||
assert_eq!(saved.content.as_str(), "updated");
|
||||
|
||||
let events = store.events.lock().unwrap();
|
||||
assert!(events.iter().any(|e| matches!(e, DomainEvent::ThoughtUpdated { thought_id, .. } if thought_id == &tid)));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn create_reply_sets_in_reply_to_id() {
|
||||
let store = TestStore::default();
|
||||
let alice = user();
|
||||
store.users.lock().unwrap().push(alice.clone());
|
||||
let original = create_thought(&store, &store, &NoOpEventPublisher, input(alice.id.clone())).await.unwrap().thought;
|
||||
|
||||
create_thought(&store, &store, &NoOpEventPublisher, CreateThoughtInput {
|
||||
user_id: alice.id.clone(),
|
||||
content: "reply".into(),
|
||||
in_reply_to_id: Some(original.id.clone()),
|
||||
visibility: None,
|
||||
content_warning: None,
|
||||
sensitive: false,
|
||||
}).await.unwrap();
|
||||
|
||||
let thoughts = store.thoughts.lock().unwrap();
|
||||
let reply = thoughts.iter().find(|t| t.content.as_str() == "reply").unwrap();
|
||||
assert_eq!(reply.in_reply_to_id, Some(original.id.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user