summaryrefslogtreecommitdiffstats
path: root/models/issue_reaction_test.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2019-12-31 09:21:21 +0100
committertechknowlogick <techknowlogick@gitea.io>2019-12-31 03:21:21 -0500
commit9600c27085df3f895b2128f1b77aa0ce0b57e7f2 (patch)
tree9dfbbf44126e7c39b77558ec943c8a2b9a717b10 /models/issue_reaction_test.go
parent655aea13a5ad5dd51bcaafd1b96ecce2673f0312 (diff)
downloadgitea-9600c27085df3f895b2128f1b77aa0ce0b57e7f2.tar.gz
gitea-9600c27085df3f895b2128f1b77aa0ce0b57e7f2.zip
[API] Fix 9544 | return 200 when reaction already exist (#9550)
* add ErrReactionAlreadyExist * extend CreateReaction * reaction already exist = 200 * extend FindReactionsOptions * refactor swagger options/definitions * fix swagger-validate * Update models/error.go Co-Authored-By: zeripath <art27@cantab.net> * fix test PART1 * extend FindReactionsOptions with UserID option * catch error on test * fix test PART2 * format ... Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: techknowlogick <matti@mdranta.net>
Diffstat (limited to 'models/issue_reaction_test.go')
-rw-r--r--models/issue_reaction_test.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/models/issue_reaction_test.go b/models/issue_reaction_test.go
index 1189b389e9..723a6be536 100644
--- a/models/issue_reaction_test.go
+++ b/models/issue_reaction_test.go
@@ -50,9 +50,10 @@ func TestIssueAddDuplicateReaction(t *testing.T) {
Type: "heart",
})
assert.Error(t, err)
- assert.Nil(t, reaction)
+ assert.Equal(t, ErrReactionAlreadyExist{Reaction: "heart"}, err)
- AssertExistsAndLoadBean(t, &Reaction{Type: "heart", UserID: user1.ID, IssueID: issue1.ID})
+ existingR := AssertExistsAndLoadBean(t, &Reaction{Type: "heart", UserID: user1.ID, IssueID: issue1.ID}).(*Reaction)
+ assert.Equal(t, existingR.ID, reaction.ID)
}
func TestIssueDeleteReaction(t *testing.T) {
@@ -129,7 +130,6 @@ func TestIssueCommentDeleteReaction(t *testing.T) {
user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
user3 := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
user4 := AssertExistsAndLoadBean(t, &User{ID: 4}).(*User)
- ghost := NewGhostUser()
issue1 := AssertExistsAndLoadBean(t, &Issue{ID: 1}).(*Issue)
@@ -139,14 +139,13 @@ func TestIssueCommentDeleteReaction(t *testing.T) {
addReaction(t, user2, issue1, comment1, "heart")
addReaction(t, user3, issue1, comment1, "heart")
addReaction(t, user4, issue1, comment1, "+1")
- addReaction(t, ghost, issue1, comment1, "heart")
err := comment1.LoadReactions()
assert.NoError(t, err)
- assert.Len(t, comment1.Reactions, 5)
+ assert.Len(t, comment1.Reactions, 4)
reactions := comment1.Reactions.GroupByType()
- assert.Len(t, reactions["heart"], 4)
+ assert.Len(t, reactions["heart"], 3)
assert.Len(t, reactions["+1"], 1)
}
@@ -160,7 +159,7 @@ func TestIssueCommentReactionCount(t *testing.T) {
comment1 := AssertExistsAndLoadBean(t, &Comment{ID: 1}).(*Comment)
addReaction(t, user1, issue1, comment1, "heart")
- DeleteCommentReaction(user1, issue1, comment1, "heart")
+ assert.NoError(t, DeleteCommentReaction(user1, issue1, comment1, "heart"))
AssertNotExistsBean(t, &Reaction{Type: "heart", UserID: user1.ID, IssueID: issue1.ID, CommentID: comment1.ID})
}