Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devinburnette committed Sep 11, 2022
1 parent 4b84279 commit 1b4c175
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions policy/approval/approve.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (r *Rule) Evaluate(ctx context.Context, prctx pull.Context) (res common.Res
}
res.PredicateResults = predicateResults

allowedReviews, discardedReviews, err := r.filteredCandidates(ctx, prctx)
allowedReviews, discardedReviews, err := r.FilteredCandidates(ctx, prctx)
if err != nil {
res.Error = errors.Wrap(err, "failed to filter candidates")
return
Expand Down Expand Up @@ -256,7 +256,7 @@ func (r *Rule) IsApproved(ctx context.Context, prctx pull.Context, candidates []
return false, msg, nil
}

func (r *Rule) filteredCandidates(ctx context.Context, prctx pull.Context) ([]*common.Candidate, []*common.DiscardedReview, error) {
func (r *Rule) FilteredCandidates(ctx context.Context, prctx pull.Context) ([]*common.Candidate, []*common.DiscardedReview, error) {
candidates, err := r.Options.GetMethods().Candidates(ctx, prctx)
if err != nil {
return nil, nil, errors.Wrap(err, "failed to get approval candidates")
Expand Down
8 changes: 6 additions & 2 deletions policy/approval/approve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ func TestIsApproved(t *testing.T) {
}

assertApproved := func(t *testing.T, prctx pull.Context, r *Rule, expected string) {
approved, msg, err := r.IsApproved(ctx, prctx, candidates)
allowedCandidates, _, _ := r.FilteredCandidates(ctx, prctx)

approved, msg, err := r.IsApproved(ctx, prctx, allowedCandidates)
require.NoError(t, err)

if assert.True(t, approved, "pull request was not approved") {
Expand All @@ -144,7 +146,9 @@ func TestIsApproved(t *testing.T) {
}

assertPending := func(t *testing.T, prctx pull.Context, r *Rule, expected string) {
approved, msg, err := r.IsApproved(ctx, prctx, candidates)
allowedCandidates, _, _ := r.FilteredCandidates(ctx, prctx)

approved, msg, err := r.IsApproved(ctx, prctx, allowedCandidates)
require.NoError(t, err)

if assert.False(t, approved, "pull request was incorrectly approved") {
Expand Down

0 comments on commit 1b4c175

Please sign in to comment.