diff options
author | David Svantesson <davidsvantesson@gmail.com> | 2019-12-04 02:08:56 +0100 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-12-03 20:08:56 -0500 |
commit | bac4b78e0908c0cb01a3842436950c7bcf793cf9 (patch) | |
tree | a3c80aebb1ca69bf6e518b881229158dccf4ddd7 /models/review_test.go | |
parent | 6460284085b0b416d61c57d729d47e932ac05efe (diff) | |
download | gitea-bac4b78e0908c0cb01a3842436950c7bcf793cf9.tar.gz gitea-bac4b78e0908c0cb01a3842436950c7bcf793cf9.zip |
Branch protection: Possibility to not use whitelist but allow anyone with write access (#9055)
* Possibility to not use whitelist but allow anyone with write access
* fix existing test
* rename migration function
* Try to give a better name for migration step
* Clear settings if higher level setting is not set
* Move official reviews to db instead of counting approvals each time
* migration
* fix
* fix migration
* fix migration
* Remove NOT NULL from EnableWhitelist as migration isn't possible
* Fix migration, reviews are connected to issues.
* Fix SQL query issues in GetReviewersByPullID.
* Simplify function GetReviewersByIssueID
* Handle reviewers that has been deleted
* Ensure reviews for test is in a well defined order
* Only clear and set official reviews when it is an approve or reject.
Diffstat (limited to 'models/review_test.go')
-rw-r--r-- | models/review_test.go | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/models/review_test.go b/models/review_test.go index 3e7563b434..a94a65f754 100644 --- a/models/review_test.go +++ b/models/review_test.go @@ -98,7 +98,7 @@ func TestCreateReview(t *testing.T) { AssertExistsAndLoadBean(t, &Review{Content: "New Review"}) } -func TestGetReviewersByPullID(t *testing.T) { +func TestGetReviewersByIssueID(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) issue := AssertExistsAndLoadBean(t, &Issue{ID: 3}).(*Issue) @@ -106,24 +106,29 @@ func TestGetReviewersByPullID(t *testing.T) { 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, + expectedReviews := []*Review{} + expectedReviews = append(expectedReviews, + &Review{ + Reviewer: user3, + Type: ReviewTypeReject, + UpdatedUnix: 946684812, }, - &PullReviewersWithType{ - User: *user4, - Type: ReviewTypeApprove, - ReviewUpdatedUnix: 946684810, + &Review{ + Reviewer: user4, + Type: ReviewTypeApprove, + UpdatedUnix: 946684813, + }, + &Review{ + Reviewer: user2, + Type: ReviewTypeReject, + UpdatedUnix: 946684814, }) - allReviews, err := GetReviewersByPullID(issue.ID) + allReviews, err := GetReviewersByIssueID(issue.ID) assert.NoError(t, err) - assert.Equal(t, expectedReviews, allReviews) + for i, review := range allReviews { + assert.Equal(t, expectedReviews[i].Reviewer, review.Reviewer) + assert.Equal(t, expectedReviews[i].Type, review.Type) + assert.Equal(t, expectedReviews[i].UpdatedUnix, review.UpdatedUnix) + } } |