Skip to content

Commit

Permalink
Add test for ensuring only admins can be maintainers
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhita committed Mar 7, 2019
1 parent 9bf2dc1 commit b374aa4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ func testTeamMembers(teams map[string]org.Team, admins sets.String, orgMembers s
teamMaintainers = normalize(teamMaintainers)
teamMembers = normalize(teamMembers)

// check for non-admins in maintainers list
if nonAdminMaintainers := teamMaintainers.Difference(admins); len(nonAdminMaintainers) > 0 {
errs = append(errs, fmt.Errorf("The team %s in org %s has non-admins listed as maintainers; these users should be in the members list instead: %s", teamName, orgName, strings.Join(nonAdminMaintainers.List(), ",")))
}

// check for users in both maintainers and members
if both := teamMaintainers.Intersection(teamMembers); len(both) > 0 {
errs = append(errs, fmt.Errorf("The team %s in org %s has users in both maintainer admin and member roles: %s", teamName, orgName, strings.Join(both.List(), ", ")))
Expand All @@ -122,9 +127,6 @@ func testTeamMembers(teams map[string]org.Team, admins sets.String, orgMembers s
}

// check if all are org members
if missing := teamMaintainers.Difference(orgMembers); len(missing) > 0 {
errs = append(errs, fmt.Errorf("The following maintainers of team %s are not %s org members: %s", teamName, orgName, strings.Join(missing.List(), ", ")))
}
if missing := teamMembers.Difference(orgMembers); len(missing) > 0 {
errs = append(errs, fmt.Errorf("The following members of team %s are not %s org members: %s", teamName, orgName, strings.Join(missing.List(), ", ")))
}
Expand Down

0 comments on commit b374aa4

Please sign in to comment.