summaryrefslogtreecommitdiffstats
path: root/models/issue_comment_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-07-26 18:20:38 -0700
committerLunny Xiao <xiaolunwen@gmail.com>2017-07-27 09:20:38 +0800
commita27863b6d15026cf36b164707331fd59ffb68931 (patch)
tree82bd393e796d4330213599b492b40b0100288c8a /models/issue_comment_test.go
parent5f37944dff7f8e48b3c5ce27bd1b77907b71f092 (diff)
downloadgitea-a27863b6d15026cf36b164707331fd59ffb68931.tar.gz
gitea-a27863b6d15026cf36b164707331fd59ffb68931.zip
Fix issue updated_unix bug (#2204)
Diffstat (limited to 'models/issue_comment_test.go')
-rw-r--r--models/issue_comment_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/models/issue_comment_test.go b/models/issue_comment_test.go
new file mode 100644
index 0000000000..86fc32a8d3
--- /dev/null
+++ b/models/issue_comment_test.go
@@ -0,0 +1,41 @@
+// Copyright 2017 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package models
+
+import (
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestCreateComment(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ issue := AssertExistsAndLoadBean(t, &Issue{}).(*Issue)
+ repo := AssertExistsAndLoadBean(t, &Repository{ID: issue.RepoID}).(*Repository)
+ doer := AssertExistsAndLoadBean(t, &User{ID: repo.OwnerID}).(*User)
+
+ now := time.Now().Unix()
+ comment, err := CreateComment(&CreateCommentOptions{
+ Type: CommentTypeComment,
+ Doer: doer,
+ Repo: repo,
+ Issue: issue,
+ Content: "Hello",
+ })
+ assert.NoError(t, err)
+ then := time.Now().Unix()
+
+ assert.EqualValues(t, CommentTypeComment, comment.Type)
+ assert.EqualValues(t, "Hello", comment.Content)
+ assert.EqualValues(t, issue.ID, comment.IssueID)
+ assert.EqualValues(t, doer.ID, comment.PosterID)
+ AssertInt64InRange(t, now, then, comment.CreatedUnix)
+ AssertExistsAndLoadBean(t, comment) // assert actually added to DB
+
+ updatedIssue := AssertExistsAndLoadBean(t, &Issue{ID: issue.ID}).(*Issue)
+ AssertInt64InRange(t, now, then, updatedIssue.UpdatedUnix)
+}