wip
This commit is contained in:
parent
a7d81d6013
commit
68ba45ca9c
@ -125,9 +125,13 @@ func IsPrjGitPRApproved(gitea common.GiteaMaintainershipInterface, giteapr Gitea
|
||||
}
|
||||
}
|
||||
|
||||
requiredReviews := slices.Clone(config.Reviewers)
|
||||
for _, r := range prjPR.reviews {
|
||||
|
||||
if !r.Stale && r.State == common.ReviewStateApproved && slices.Contains(requiredReviews, r.User.UserName) {
|
||||
idx := slices.Index(requiredReviews, r.User.UserName)
|
||||
requiredReviews = slices.Delete(requiredReviews, idx, idx+1)
|
||||
}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return len(requiredReviews) == 0, nil
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func TestReviewApproval(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "Maintainer not approved",
|
||||
pr: &models.PullRequest{Body: "", Index: 10, RequestedReviewers: []*models.User{}},
|
||||
pr: &models.PullRequest{Body: "PR: foo/foo#10", Index: 10, RequestedReviewers: []*models.User{}},
|
||||
reviews: []*models.PullReview{},
|
||||
|
||||
maintainerFile: []byte(`{"foo": ["bingo"]}`),
|
||||
@ -217,8 +217,8 @@ func TestReviewApproval(t *testing.T) {
|
||||
mi.EXPECT().FetchMaintainershipFile("foo", common.DefaultGitPrj, "bar").Return(test.maintainerFile, nil)
|
||||
|
||||
approved, err := IsPrjGitPRApproved(mi, pri, config, 10)
|
||||
if approved == test.approved {
|
||||
t.Error("Unexpected approved or err:", err)
|
||||
if approved != test.approved {
|
||||
t.Error("Unexpected approve state:", approved, "vs. expected", test.approved, ", or err:", err)
|
||||
}
|
||||
if err != nil {
|
||||
t.Error("Unexpected error", err)
|
||||
|
Loading…
Reference in New Issue
Block a user