Files
autogits/common/reviewers_test.go
Adam Majer 79e5345ac6 test: refactor loggin in unit tests
Use test logger when running under a test.
2026-01-31 10:04:08 +01:00

57 lines
1.4 KiB
Go

package common_test
import (
"slices"
"testing"
"src.opensuse.org/autogits/common"
)
func TestReviewers(t *testing.T) {
common.SetTestLogger(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"},
pkg: []string{"1", "2", "3", "5", "6"},
},
{
name: "optional project and package reviewers",
input: []string{"~1", "2", "3", "~*5", "+6", "-7"},
prj: []string{"7"},
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)
}
})
}
}