Skip to content

Commit

Permalink
its: Add IssueComment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Aug 2, 2022
1 parent 1bcd8d3 commit 1e6cdd0
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions its/crates/domain/src/domain/aggregate/issue_comment/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod tests {
use super::*;

#[test]
fn test() -> anyhow::Result<()> {
fn from_event_test() -> anyhow::Result<()> {
let at = Instant::now();
let issue_comment_id = IssueCommentId::generate();
let issue_id = IssueId::from_str("123")?;
Expand All @@ -98,7 +98,19 @@ mod tests {
assert_eq!(issue_comment.id, issue_comment_id);
assert_eq!(issue_comment.issue_id, issue_id);
assert_eq!(issue_comment.text, text);
// TODO
Ok(())
}

#[test]
fn new_test() -> anyhow::Result<()> {
let issue_comment_id = IssueCommentId::generate();
let issue_id = IssueId::from_str("123")?;
let text = IssueCommentText::from_str("text")?;
let issue_comment =
IssueComment::new(issue_comment_id.clone(), issue_id.clone(), text.clone());
assert_eq!(issue_comment.id, issue_comment_id);
assert_eq!(issue_comment.issue_id, issue_id);
assert_eq!(issue_comment.text, text);
Ok(())
}

Expand Down Expand Up @@ -128,5 +140,22 @@ mod tests {
Ok(())
}

// TODO: update test
#[test]
fn update_test() -> anyhow::Result<()> {
let issue_comment_id = IssueCommentId::generate();
let issue_id = IssueId::from_str("123")?;
let text = IssueCommentText::from_str("text1")?;
let issue_comment = IssueComment::new(issue_comment_id, issue_id, text);
assert_eq!(issue_comment.text.to_string(), "text1");

let text = IssueCommentText::from_str("text2")?;
let updated = issue_comment.update(text)?;
assert_eq!(updated.text.to_string(), "text2");

let deleted = updated.delete()?;
let text = IssueCommentText::from_str("text3")?;
assert!(deleted.update(text).is_err());

Ok(())
}
}

0 comments on commit 1e6cdd0

Please sign in to comment.