forked from adamm/autogits
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package common_test
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
|
|
"src.opensuse.org/autogits/common"
|
|
)
|
|
|
|
func TestReviewers(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input []string
|
|
|
|
prj []string
|
|
pkg []string
|
|
pkg_optional []string
|
|
prj_optional []string
|
|
}{
|
|
{
|
|
name: "project and package reviewers",
|
|
input: []string{"1", "2", "3", "*5", "+6", "-7"},
|
|
|
|
prj: []string{"5", "7", common.Bot_BuildReview},
|
|
pkg: []string{"1", "2", "3", "5", "6"},
|
|
},
|
|
{
|
|
name: "optional project and package reviewers",
|
|
input: []string{"~1", "2", "3", "~*5", "+6", "-7"},
|
|
|
|
prj: []string{"7", common.Bot_BuildReview},
|
|
pkg: []string{"2", "3", "6"},
|
|
prj_optional: []string{"5"},
|
|
pkg_optional: []string{"1", "5"},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
reviewers := common.ParseReviewers(test.input)
|
|
if !slices.Equal(reviewers.Prj, test.prj) {
|
|
t.Error("unexpected return of ForProject():", reviewers.Prj)
|
|
}
|
|
if !slices.Equal(reviewers.Pkg, test.pkg) {
|
|
t.Error("unexpected return of ForPackage():", reviewers.Pkg)
|
|
}
|
|
if !slices.Equal(reviewers.PrjOptional, test.prj_optional) {
|
|
t.Error("unexpected return of ForProjectOptional():", reviewers.Prj)
|
|
}
|
|
if !slices.Equal(reviewers.PkgOptional, test.pkg_optional) {
|
|
t.Error("unexpected return of ForPackageOptional():", reviewers.Pkg)
|
|
}
|
|
})
|
|
}
|
|
}
|