Skip to content

Commit

Permalink
fix: add test to ensure only bots are configured as single approver a…
Browse files Browse the repository at this point in the history
…uthors
  • Loading branch information
jimbishopp committed Dec 29, 2023
1 parent 06c4248 commit 6e2ca8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bot/internal/review/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var (

// singleApproverAuthors defines pull request authors in cloud or core repos that only
// require a single approver. The map key is the repo (cloud|teleport|teleport.e) and the
// value is a list of authors.
// value is a list of authors. BOTS ONLY - DO NOT INCLUDE EMPLOYEE GITHUB HANDLES.
singleApproverAuthors = map[string][]string{
"cloud": []string{Dependabot, DependabotBatcher, RenovateBotPrivate, RenovateBotPublic},
}
Expand Down
16 changes: 16 additions & 0 deletions bot/internal/review/review_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package review

import (
"slices"
"sort"
"testing"

Expand Down Expand Up @@ -1192,6 +1193,21 @@ func TestPreferredReviewers(t *testing.T) {
}
}

func TestSingleApproverAuthors(t *testing.T) {
name := func(authors []string, i int) string {
if i == -1 {
return ""
}
return authors[i]
}
for repo, authors := range singleApproverAuthors {
i := slices.IndexFunc(authors, func(author string) bool {
return !isAllowedRobot(author)
})
require.Equal(t, -1, i, "%q is not allowed to be a single approver author in the %q repository (only bots)", name(authors, i), repo)
}
}

const reviewers = `
{
"codeReviewers": {
Expand Down

0 comments on commit 6e2ca8f

Please sign in to comment.