From f851bc7ce5a0d9debae0cb127d4fffe47771e105 Mon Sep 17 00:00:00 2001 From: yongruilin Date: Wed, 22 Oct 2025 22:38:16 +0000 Subject: [PATCH] test(validation): add cases HardwareAddress length in ResourceClaim status --- .../declarative_validation_test.go | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/registry/resource/resourceclaim/declarative_validation_test.go b/pkg/registry/resource/resourceclaim/declarative_validation_test.go index c330b5485fb..5ebb1fca949 100644 --- a/pkg/registry/resource/resourceclaim/declarative_validation_test.go +++ b/pkg/registry/resource/resourceclaim/declarative_validation_test.go @@ -1161,6 +1161,39 @@ func testValidateStatusUpdateForDeclarative(t *testing.T, apiVersion string) { field.TooLong(field.NewPath("status", "devices").Index(0).Child("networkData", "interfaceName"), "", resource.NetworkDeviceDataInterfaceNameMaxLength).MarkCoveredByDeclarative().WithOrigin("maxLength"), }, }, + "valid status.devices.networkData.hardwareAddress": { + old: mkValidResourceClaim(), + update: mkResourceClaimWithStatus( + tweakStatusDevices( + resource.AllocatedDeviceStatus{ + Driver: "dra.example.com", + Pool: "pool-0", + Device: "device-0", + NetworkData: &resource.NetworkDeviceData{ + HardwareAddress: strings.Repeat("a", resource.NetworkDeviceDataHardwareAddressMaxLength), + }, + }, + ), + ), + }, + "invalid status.devices.networkData.hardwareAddress too long": { + old: mkValidResourceClaim(), + update: mkResourceClaimWithStatus( + tweakStatusDevices( + resource.AllocatedDeviceStatus{ + Driver: "dra.example.com", + Pool: "pool-0", + Device: "device-0", + NetworkData: &resource.NetworkDeviceData{ + HardwareAddress: strings.Repeat("a", resource.NetworkDeviceDataHardwareAddressMaxLength+1), + }, + }, + ), + ), + expectedErrs: field.ErrorList{ + field.TooLong(field.NewPath("status", "devices").Index(0).Child("networkData", "hardwareAddress"), "", resource.NetworkDeviceDataHardwareAddressMaxLength).MarkCoveredByDeclarative().WithOrigin("maxLength"), + }, + }, } for k, tc := range testCases {