mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
flowcontrol: cover Required rule for spec.type and limitResponse.type
Add declarative-validation test cases for empty Spec.Type and empty LimitResponse.Type, closing the FieldValueRequired coverage gap reported for PriorityLevelConfiguration across v1, v1beta1, v1beta2, v1beta3.
This commit is contained in:
parent
177d2ae7a1
commit
55baca8a46
1 changed files with 19 additions and 0 deletions
|
|
@ -103,6 +103,18 @@ func testDeclarativeValidate(t *testing.T, apiVersion string) {
|
|||
field.Forbidden(specPath.Child("limited", "limitResponse", "queuing"), "").MarkCoveredByDeclarative().MarkAlpha(),
|
||||
},
|
||||
},
|
||||
"spec.type: empty": {
|
||||
input: mkPLC(tweakSpecType(""), tweakLimited(nil)),
|
||||
expectedErrs: field.ErrorList{
|
||||
field.Required(specPath.Child("type"), "").MarkCoveredByDeclarative().MarkAlpha(),
|
||||
},
|
||||
},
|
||||
"limitResponse.type: empty": {
|
||||
input: mkPLC(tweakLimitResponseType("")),
|
||||
expectedErrs: field.ErrorList{
|
||||
field.Required(specPath.Child("limited", "limitResponse", "type"), "").MarkCoveredByDeclarative().MarkAlpha(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
|
|
@ -226,6 +238,13 @@ func tweakLimited(limited *flowcontrol.LimitedPriorityLevelConfiguration) func(*
|
|||
}
|
||||
}
|
||||
|
||||
// tweakSpecType sets the Spec.Type field directly.
|
||||
func tweakSpecType(t flowcontrol.PriorityLevelEnablement) func(*flowcontrol.PriorityLevelConfiguration) {
|
||||
return func(obj *flowcontrol.PriorityLevelConfiguration) {
|
||||
obj.Spec.Type = t
|
||||
}
|
||||
}
|
||||
|
||||
// tweakExemptConfig sets the Exempt configuration field.
|
||||
func tweakExemptConfig(exempt *flowcontrol.ExemptPriorityLevelConfiguration) func(*flowcontrol.PriorityLevelConfiguration) {
|
||||
return func(obj *flowcontrol.PriorityLevelConfiguration) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue