@@ -162,6 +162,7 @@ func TestDropManagedFieldsWithFakeClient(t *testing.T) {
162
162
Operation : metav1 .ManagedFieldsOperationUpdate ,
163
163
FieldsType : "FieldsV1" ,
164
164
FieldsV1 : & metav1.FieldsV1 {Raw : fieldV1 },
165
+ APIVersion : "v1" ,
165
166
}},
166
167
Labels : map [string ]string {
167
168
"label-1" : "value-1" ,
@@ -186,10 +187,13 @@ func TestDropManagedFieldsWithFakeClient(t *testing.T) {
186
187
Operation : metav1 .ManagedFieldsOperationUpdate ,
187
188
FieldsType : "FieldsV1" ,
188
189
FieldsV1 : & metav1.FieldsV1 {Raw : fieldV1 },
190
+ APIVersion : "v1" ,
189
191
},
190
192
{
191
- Manager : ssaManager ,
192
- Operation : metav1 .ManagedFieldsOperationApply ,
193
+ Manager : ssaManager ,
194
+ Operation : metav1 .ManagedFieldsOperationApply ,
195
+ FieldsType : "FieldsV1" ,
196
+ APIVersion : "v1" ,
193
197
},
194
198
},
195
199
Labels : map [string ]string {
@@ -225,7 +229,7 @@ func TestDropManagedFieldsWithFakeClient(t *testing.T) {
225
229
for _ , tt := range tests {
226
230
t .Run (tt .name , func (t * testing.T ) {
227
231
g := NewWithT (t )
228
- fakeClient := fake .NewClientBuilder ().WithObjects (tt .obj ).Build ()
232
+ fakeClient := fake .NewClientBuilder ().WithObjects (tt .obj ).WithReturnManagedFields (). Build ()
229
233
labelsAndAnnotationsManagedFieldPaths := []contract.Path {
230
234
{"f:metadata" , "f:annotations" },
231
235
{"f:metadata" , "f:labels" },
@@ -416,6 +420,8 @@ func TestCleanUpManagedFieldsForSSAAdoptionWithFakeClient(t *testing.T) {
416
420
ManagedFields : []metav1.ManagedFieldsEntry {{
417
421
Manager : classicManager ,
418
422
Operation : metav1 .ManagedFieldsOperationUpdate ,
423
+ FieldsType : "FieldsV1" ,
424
+ APIVersion : "v1" ,
419
425
}},
420
426
},
421
427
Data : map [string ]string {
@@ -429,6 +435,8 @@ func TestCleanUpManagedFieldsForSSAAdoptionWithFakeClient(t *testing.T) {
429
435
ManagedFields : []metav1.ManagedFieldsEntry {{
430
436
Manager : ssaManager ,
431
437
Operation : metav1 .ManagedFieldsOperationApply ,
438
+ FieldsType : "FieldsV1" ,
439
+ APIVersion : "v1" ,
432
440
}},
433
441
},
434
442
Data : map [string ]string {
@@ -443,10 +451,14 @@ func TestCleanUpManagedFieldsForSSAAdoptionWithFakeClient(t *testing.T) {
443
451
{
444
452
Manager : classicManager ,
445
453
Operation : metav1 .ManagedFieldsOperationUpdate ,
454
+ FieldsType : "FieldsV1" ,
455
+ APIVersion : "v1" ,
446
456
},
447
457
{
448
458
Manager : ssaManager ,
449
459
Operation : metav1 .ManagedFieldsOperationApply ,
460
+ FieldsType : "FieldsV1" ,
461
+ APIVersion : "v1" ,
450
462
},
451
463
},
452
464
},
@@ -485,7 +497,7 @@ func TestCleanUpManagedFieldsForSSAAdoptionWithFakeClient(t *testing.T) {
485
497
for _ , tt := range tests {
486
498
t .Run (tt .name , func (t * testing.T ) {
487
499
g := NewWithT (t )
488
- fakeClient := fake .NewClientBuilder ().WithObjects (tt .obj ).Build ()
500
+ fakeClient := fake .NewClientBuilder ().WithObjects (tt .obj ).WithReturnManagedFields (). Build ()
489
501
g .Expect (CleanUpManagedFieldsForSSAAdoption (ctx , fakeClient , tt .obj , ssaManager )).Should (Succeed ())
490
502
g .Expect (tt .obj .GetManagedFields ()).Should (
491
503
ContainElement (MatchManagedFieldsEntry (ssaManager , metav1 .ManagedFieldsOperationApply )))
0 commit comments