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.
This commit is contained in:

committed by
techknowlogick

parent
6460284085
commit
bac4b78e09
@ -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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user