aboutsummaryrefslogtreecommitdiffstats
path: root/models/review_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/review_test.go')
-rw-r--r--models/review_test.go55
1 files changed, 27 insertions, 28 deletions
diff --git a/models/review_test.go b/models/review_test.go
index 31d6c45535..2d07ea2ce4 100644
--- a/models/review_test.go
+++ b/models/review_test.go
@@ -7,7 +7,6 @@ package models
import (
"testing"
- "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
"github.com/stretchr/testify/assert"
)
@@ -26,22 +25,22 @@ func TestGetReviewByID(t *testing.T) {
func TestReview_LoadAttributes(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- review := db.AssertExistsAndLoadBean(t, &Review{ID: 1}).(*Review)
+ review := unittest.AssertExistsAndLoadBean(t, &Review{ID: 1}).(*Review)
assert.NoError(t, review.LoadAttributes())
assert.NotNil(t, review.Issue)
assert.NotNil(t, review.Reviewer)
- invalidReview1 := db.AssertExistsAndLoadBean(t, &Review{ID: 2}).(*Review)
+ invalidReview1 := unittest.AssertExistsAndLoadBean(t, &Review{ID: 2}).(*Review)
assert.Error(t, invalidReview1.LoadAttributes())
- invalidReview2 := db.AssertExistsAndLoadBean(t, &Review{ID: 3}).(*Review)
+ invalidReview2 := unittest.AssertExistsAndLoadBean(t, &Review{ID: 3}).(*Review)
assert.Error(t, invalidReview2.LoadAttributes())
}
func TestReview_LoadCodeComments(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- review := db.AssertExistsAndLoadBean(t, &Review{ID: 4}).(*Review)
+ review := unittest.AssertExistsAndLoadBean(t, &Review{ID: 4}).(*Review)
assert.NoError(t, review.LoadAttributes())
assert.NoError(t, review.LoadCodeComments())
assert.Len(t, review.CodeComments, 1)
@@ -71,8 +70,8 @@ func TestFindReviews(t *testing.T) {
func TestGetCurrentReview(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- issue := db.AssertExistsAndLoadBean(t, &Issue{ID: 2}).(*Issue)
- user := db.AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
+ issue := unittest.AssertExistsAndLoadBean(t, &Issue{ID: 2}).(*Issue)
+ user := unittest.AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
review, err := GetCurrentReview(user, issue)
assert.NoError(t, err)
@@ -80,7 +79,7 @@ func TestGetCurrentReview(t *testing.T) {
assert.Equal(t, ReviewTypePending, review.Type)
assert.Equal(t, "Pending Review", review.Content)
- user2 := db.AssertExistsAndLoadBean(t, &User{ID: 7}).(*User)
+ user2 := unittest.AssertExistsAndLoadBean(t, &User{ID: 7}).(*User)
review2, err := GetCurrentReview(user2, issue)
assert.Error(t, err)
assert.True(t, IsErrReviewNotExist(err))
@@ -90,8 +89,8 @@ func TestGetCurrentReview(t *testing.T) {
func TestCreateReview(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- issue := db.AssertExistsAndLoadBean(t, &Issue{ID: 2}).(*Issue)
- user := db.AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
+ issue := unittest.AssertExistsAndLoadBean(t, &Issue{ID: 2}).(*Issue)
+ user := unittest.AssertExistsAndLoadBean(t, &User{ID: 1}).(*User)
review, err := CreateReview(CreateReviewOptions{
Content: "New Review",
@@ -101,16 +100,16 @@ func TestCreateReview(t *testing.T) {
})
assert.NoError(t, err)
assert.Equal(t, "New Review", review.Content)
- db.AssertExistsAndLoadBean(t, &Review{Content: "New Review"})
+ unittest.AssertExistsAndLoadBean(t, &Review{Content: "New Review"})
}
func TestGetReviewersByIssueID(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- issue := db.AssertExistsAndLoadBean(t, &Issue{ID: 3}).(*Issue)
- user2 := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
- user3 := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
- user4 := db.AssertExistsAndLoadBean(t, &User{ID: 4}).(*User)
+ issue := unittest.AssertExistsAndLoadBean(t, &Issue{ID: 3}).(*Issue)
+ user2 := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ user3 := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ user4 := unittest.AssertExistsAndLoadBean(t, &User{ID: 4}).(*User)
expectedReviews := []*Review{}
expectedReviews = append(expectedReviews,
@@ -147,43 +146,43 @@ func TestGetReviewersByIssueID(t *testing.T) {
func TestDismissReview(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- rejectReviewExample := db.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
- requestReviewExample := db.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
- approveReviewExample := db.AssertExistsAndLoadBean(t, &Review{ID: 8}).(*Review)
+ rejectReviewExample := unittest.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
+ requestReviewExample := unittest.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
+ approveReviewExample := unittest.AssertExistsAndLoadBean(t, &Review{ID: 8}).(*Review)
assert.False(t, rejectReviewExample.Dismissed)
assert.False(t, requestReviewExample.Dismissed)
assert.False(t, approveReviewExample.Dismissed)
assert.NoError(t, DismissReview(rejectReviewExample, true))
- rejectReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
- requestReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
+ rejectReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
+ requestReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
assert.True(t, rejectReviewExample.Dismissed)
assert.False(t, requestReviewExample.Dismissed)
assert.NoError(t, DismissReview(requestReviewExample, true))
- rejectReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
- requestReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
+ rejectReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
+ requestReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
assert.True(t, rejectReviewExample.Dismissed)
assert.False(t, requestReviewExample.Dismissed)
assert.False(t, approveReviewExample.Dismissed)
assert.NoError(t, DismissReview(requestReviewExample, true))
- rejectReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
- requestReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
+ rejectReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
+ requestReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
assert.True(t, rejectReviewExample.Dismissed)
assert.False(t, requestReviewExample.Dismissed)
assert.False(t, approveReviewExample.Dismissed)
assert.NoError(t, DismissReview(requestReviewExample, false))
- rejectReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
- requestReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
+ rejectReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
+ requestReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
assert.True(t, rejectReviewExample.Dismissed)
assert.False(t, requestReviewExample.Dismissed)
assert.False(t, approveReviewExample.Dismissed)
assert.NoError(t, DismissReview(requestReviewExample, false))
- rejectReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
- requestReviewExample = db.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
+ rejectReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 9}).(*Review)
+ requestReviewExample = unittest.AssertExistsAndLoadBean(t, &Review{ID: 11}).(*Review)
assert.True(t, rejectReviewExample.Dismissed)
assert.False(t, requestReviewExample.Dismissed)
assert.False(t, approveReviewExample.Dismissed)