aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/comment_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/issues/comment_test.go')
-rw-r--r--models/issues/comment_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/models/issues/comment_test.go b/models/issues/comment_test.go
index d766625be3..90db476571 100644
--- a/models/issues/comment_test.go
+++ b/models/issues/comment_test.go
@@ -70,3 +70,30 @@ func TestAsCommentType(t *testing.T) {
assert.Equal(t, issues_model.CommentTypeComment, issues_model.AsCommentType("comment"))
assert.Equal(t, issues_model.CommentTypePRUnScheduledToAutoMerge, issues_model.AsCommentType("pull_cancel_scheduled_merge"))
}
+
+func TestMigrate_InsertIssueComments(t *testing.T) {
+ assert.NoError(t, unittest.PrepareTestDatabase())
+ issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
+ _ = issue.LoadRepo(db.DefaultContext)
+ owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: issue.Repo.OwnerID})
+ reaction := &issues_model.Reaction{
+ Type: "heart",
+ UserID: owner.ID,
+ }
+
+ comment := &issues_model.Comment{
+ PosterID: owner.ID,
+ Poster: owner,
+ IssueID: issue.ID,
+ Issue: issue,
+ Reactions: []*issues_model.Reaction{reaction},
+ }
+
+ err := issues_model.InsertIssueComments([]*issues_model.Comment{comment})
+ assert.NoError(t, err)
+
+ issueModified := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
+ assert.EqualValues(t, issue.NumComments+1, issueModified.NumComments)
+
+ unittest.CheckConsistencyFor(t, &issues_model.Issue{})
+}