1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 21:31:18 +01:00
Files
descheduler/pkg/framework/plugins/removeduplicates/validation_test.go
2024-06-13 11:56:33 +08:00

49 lines
1.0 KiB
Go

package removeduplicates
import (
"testing"
"sigs.k8s.io/descheduler/pkg/api"
)
func TestValidateRemovePodsViolatingNodeTaintsArgs(t *testing.T) {
testCases := []struct {
description string
args *RemoveDuplicatesArgs
expectError bool
}{
{
description: "valid namespace args, no errors",
args: &RemoveDuplicatesArgs{
ExcludeOwnerKinds: []string{"Job"},
Namespaces: &api.Namespaces{
Include: []string{"default"},
},
},
expectError: false,
},
{
description: "invalid namespaces args, expects error",
args: &RemoveDuplicatesArgs{
ExcludeOwnerKinds: []string{"Job"},
Namespaces: &api.Namespaces{
Include: []string{"default"},
Exclude: []string{"kube-system"},
},
},
expectError: true,
},
}
for _, tc := range testCases {
t.Run(tc.description, func(t *testing.T) {
err := ValidateRemoveDuplicatesArgs(tc.args)
hasError := err != nil
if tc.expectError != hasError {
t.Error("unexpected arg validation behavior")
}
})
}
}