ReviewGroups can be added as maintainers and can be optionally expanded. This is handy when a ReviewGroup is a project maintainer
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
package common_test
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"src.opensuse.org/autogits/common"
|
|
)
|
|
|
|
func TestMaintainerGroupReplacer(t *testing.T) {
|
|
GroupName := "my_group"
|
|
|
|
tests := []struct {
|
|
name string
|
|
reviewers []string
|
|
group_members []string
|
|
|
|
output []string
|
|
}{
|
|
{
|
|
name: "empty",
|
|
},
|
|
{
|
|
name: "group not maintainer",
|
|
reviewers: []string{"a", "b"},
|
|
group_members: []string{"g1", "g2"},
|
|
output: []string{"a", "b"},
|
|
},
|
|
{
|
|
name: "group maintainer",
|
|
reviewers: []string{"b", "my_group"},
|
|
group_members: []string{"g1", "g2"},
|
|
output: []string{"b", "g1", "g2"},
|
|
},
|
|
{
|
|
name: "sorted group maintainer",
|
|
reviewers: []string{"my_group", "b"},
|
|
group_members: []string{"g1", "g2"},
|
|
output: []string{"b", "g1", "g2"},
|
|
},
|
|
{
|
|
name: "group maintainer dedup",
|
|
reviewers: []string{"my_group", "g2", "b"},
|
|
group_members: []string{"g1", "g2"},
|
|
output: []string{"b", "g1", "g2"},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
g := &common.ReviewGroup{
|
|
Name: GroupName,
|
|
Reviewers: test.group_members,
|
|
}
|
|
|
|
expandedList := g.ExpandMaintainers(test.reviewers)
|
|
if slices.Compare(expandedList, test.output) != 0 {
|
|
t.Error("Expected:", test.output, "but have", expandedList)
|
|
}
|
|
})
|
|
}
|
|
}
|