@@ -161,7 +161,7 @@ func TestEnsureFinalizers(t *testing.T) {
161161 WithObjects (cm ).
162162 WithInterceptorFuncs (interceptor.Funcs {
163163 Patch : func (ctx context.Context , c client.WithWatch , obj client.Object , patch client.Patch , opts ... client.PatchOption ) error {
164- // Parse the patch to validate it has resourceVersion
164+ // Parse the patch to validate structure
165165 patchBytes , err := patch .Data (obj )
166166 require .NoError (t , err )
167167
@@ -172,20 +172,19 @@ func TestEnsureFinalizers(t *testing.T) {
172172 metadata , ok := patchMap ["metadata" ].(map [string ]interface {})
173173 require .True (t , ok , "patch should contain metadata" )
174174
175- resourceVersion , ok := metadata ["resourceVersion" ]
176- require .True (t , ok , "patch metadata should contain resourceVersion" )
177- require .NotEmpty (t , resourceVersion , "resourceVersion should not be empty" )
178-
179175 finalizers , ok := metadata ["finalizers" ]
180176 require .True (t , ok , "patch metadata should contain finalizers" )
181177
182- // Update the object with new finalizers
178+ // Update the object with new finalizers and increment resource version
179+ // to simulate what the API server does
183180 if finalizerSlice , ok := finalizers .([]interface {}); ok {
184181 stringFinalizers := make ([]string , len (finalizerSlice ))
185182 for i , f := range finalizerSlice {
186183 stringFinalizers [i ] = f .(string )
187184 }
188185 obj .SetFinalizers (stringFinalizers )
186+ // Simulate API server incrementing resourceVersion
187+ obj .SetResourceVersion ("2" )
189188 }
190189
191190 return nil
0 commit comments