Skip to content

Commit 35cf1ed

Browse files
committed
Ensure members are sorted
1 parent 20373e9 commit 35cf1ed

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

config/config_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"io/ioutil"
2222
"os"
23+
"sort"
2324
"strings"
2425
"testing"
2526

@@ -77,6 +78,15 @@ func testDuplicates(list []string) error {
7778
return nil
7879
}
7980

81+
func isSorted(list []string) bool {
82+
items := make([]string, len(list))
83+
for _, l := range list {
84+
items = append(items, strings.ToLower(l))
85+
}
86+
87+
return sort.StringsAreSorted(items)
88+
}
89+
8090
func testOrg(targetDir string, t *testing.T) {
8191
cfg, err := loadOrg(targetDir)
8292
if err != nil {
@@ -125,6 +135,12 @@ func testOrg(targetDir string, t *testing.T) {
125135
if err := testDuplicates(own.Approvers); err != nil {
126136
t.Errorf("duplicate approvers: %v", err)
127137
}
138+
if !isSorted(cfg.Admins) {
139+
t.Errorf("admins are unsorted")
140+
}
141+
if !isSorted(cfg.Members) {
142+
t.Errorf("members are unsorted")
143+
}
128144
}
129145

130146
func TestAllOrgs(t *testing.T) {

0 commit comments

Comments
 (0)