summaryrefslogtreecommitdiffstats
path: root/models/review_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/review_test.go')
-rw-r--r--models/review_test.go32
1 files changed, 31 insertions, 1 deletions
diff --git a/models/review_test.go b/models/review_test.go
index 3c0444e7a3..f8e8086dca 100644
--- a/models/review_test.go
+++ b/models/review_test.go
@@ -74,7 +74,7 @@ func TestGetCurrentReview(t *testing.T) {
assert.Equal(t, ReviewTypePending, review.Type)
assert.Equal(t, "Pending Review", review.Content)
- user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ user2 := AssertExistsAndLoadBean(t, &User{ID: 7}).(*User)
review2, err := GetCurrentReview(user2, issue)
assert.Error(t, err)
assert.True(t, IsErrReviewNotExist(err))
@@ -105,3 +105,33 @@ func TestUpdateReview(t *testing.T) {
assert.NoError(t, UpdateReview(review))
AssertExistsAndLoadBean(t, &Review{ID: 1, Content: "Updated Review"})
}
+
+func TestGetReviewersByPullID(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ issue := AssertExistsAndLoadBean(t, &Issue{ID: 3}).(*Issue)
+ user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ user3 := AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ user4 := AssertExistsAndLoadBean(t, &User{ID: 4}).(*User)
+
+ expectedReviews := []*PullReviewersWithType{}
+ expectedReviews = append(expectedReviews, &PullReviewersWithType{
+ User: *user2,
+ Type: ReviewTypeReject,
+ ReviewUpdatedUnix: 946684810,
+ },
+ &PullReviewersWithType{
+ User: *user3,
+ Type: ReviewTypeReject,
+ ReviewUpdatedUnix: 946684810,
+ },
+ &PullReviewersWithType{
+ User: *user4,
+ Type: ReviewTypeApprove,
+ ReviewUpdatedUnix: 946684810,
+ })
+
+ allReviews, err := GetReviewersByPullID(issue.ID)
+ assert.NoError(t, err)
+ assert.Equal(t, expectedReviews, allReviews)
+}