mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-22 01:23:18 +00:00
test: add validation test for duplicate FirstAvailable names
This commit is contained in:
@@ -106,6 +106,12 @@ func testDeclarativeValidate(t *testing.T, apiVersion string) {
|
||||
field.TooMany(field.NewPath("spec", "devices", "requests").Index(0).Child("firstAvailable"), 9, 8).WithOrigin("maxItems"),
|
||||
},
|
||||
},
|
||||
"invalid firstAvailable, duplicate name": {
|
||||
input: mkValidResourceClaim(tweakDuplicateFirstAvailableName("sub-0")),
|
||||
expectedErrs: field.ErrorList{
|
||||
field.Duplicate(field.NewPath("spec", "devices", "requests").Index(0).Child("firstAvailable").Index(1), "sub-0"),
|
||||
},
|
||||
},
|
||||
"invalid selectors, too many": {
|
||||
input: mkValidResourceClaim(tweakExactlySelectors(33)),
|
||||
expectedErrs: field.ErrorList{
|
||||
@@ -220,6 +226,24 @@ func tweakDuplicateRequestName(name string) func(*resource.ResourceClaim) {
|
||||
}
|
||||
}
|
||||
|
||||
func tweakDuplicateFirstAvailableName(name string) func(*resource.ResourceClaim) {
|
||||
return func(rc *resource.ResourceClaim) {
|
||||
rc.Spec.Devices.Requests[0].Exactly = nil
|
||||
rc.Spec.Devices.Requests[0].FirstAvailable = []resource.DeviceSubRequest{
|
||||
{
|
||||
Name: name,
|
||||
DeviceClassName: "class",
|
||||
AllocationMode: resource.DeviceAllocationModeAll,
|
||||
},
|
||||
{
|
||||
Name: name,
|
||||
DeviceClassName: "class",
|
||||
AllocationMode: resource.DeviceAllocationModeAll,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func tweakExactlySelectors(items int) func(*resource.ResourceClaim) {
|
||||
return func(rc *resource.ResourceClaim) {
|
||||
for i := 0; i < items; i++ {
|
||||
|
||||
Reference in New Issue
Block a user