@@ -25,7 +25,7 @@ import (
25
25
"sigs.k8s.io/structured-merge-diff/typed"
26
26
)
27
27
28
- func TestDeducedTypesBroken (t * testing.T ) {
28
+ func TestDeduced (t * testing.T ) {
29
29
tests := map [string ]TestCase {
30
30
"leaf_apply_twice" : {
31
31
Ops : []Operation {
@@ -230,28 +230,7 @@ func TestDeducedTypesBroken(t *testing.T) {
230
230
},
231
231
},
232
232
},
233
- "leaf_apply_remove_empty_set" : {
234
- Ops : []Operation {
235
- Apply {
236
- Manager : "default" ,
237
- APIVersion : "v1" ,
238
- Object : `
239
- string: "string"
240
- ` ,
241
- },
242
- Apply {
243
- Manager : "default" ,
244
- APIVersion : "v1" ,
245
- Object : "" ,
246
- },
247
- },
248
- Object : `
249
- string: "string"
250
- ` ,
251
- Managed : fieldpath.ManagedFields {},
252
- },
253
-
254
- "apply_twice" : {
233
+ "apply_twice_list_is_atomic" : {
255
234
Ops : []Operation {
256
235
Apply {
257
236
Manager : "default" ,
@@ -268,94 +247,27 @@ func TestDeducedTypesBroken(t *testing.T) {
268
247
Object : `
269
248
list:
270
249
- a
271
- - b
272
- - c
273
250
- d
274
- ` ,
275
- },
276
- },
277
- Object : `
278
- list:
279
- - a
280
- - b
281
- - c
282
- - d
283
- ` ,
284
- Managed : fieldpath.ManagedFields {
285
- "default" : & fieldpath.VersionedSet {
286
- Set : _NS (
287
- _P ("list" , _SV ("a" )),
288
- _P ("list" , _SV ("b" )),
289
- _P ("list" , _SV ("c" )),
290
- _P ("list" , _SV ("d" )),
291
- ),
292
- APIVersion : "v1" ,
293
- },
294
- },
295
- },
296
- "apply_update_apply_no_overlap" : {
297
- Ops : []Operation {
298
- Apply {
299
- Manager : "default" ,
300
- APIVersion : "v1" ,
301
- Object : `
302
- list:
303
- - a
304
251
- c
305
- ` ,
306
- },
307
- Update {
308
- Manager : "controller" ,
309
- APIVersion : "v1" ,
310
- Object : `
311
- list:
312
- - a
313
252
- b
314
- - c
315
- - d
316
- ` ,
317
- },
318
- Apply {
319
- Manager : "default" ,
320
- APIVersion : "v1" ,
321
- Object : `
322
- list:
323
- - a
324
- - aprime
325
- - c
326
- - cprime
327
253
` ,
328
254
},
329
255
},
330
256
Object : `
331
257
list:
332
258
- a
333
- - aprime
334
- - b
335
- - c
336
- - cprime
337
259
- d
260
+ - c
261
+ - b
338
262
` ,
339
263
Managed : fieldpath.ManagedFields {
340
264
"default" : & fieldpath.VersionedSet {
341
- Set : _NS (
342
- _P ("list" , _SV ("a" )),
343
- _P ("list" , _SV ("aprime" )),
344
- _P ("list" , _SV ("c" )),
345
- _P ("list" , _SV ("cprime" )),
346
- ),
347
- APIVersion : "v1" ,
348
- },
349
- "controller" : & fieldpath.VersionedSet {
350
- Set : _NS (
351
- _P ("list" , _SV ("b" )),
352
- _P ("list" , _SV ("d" )),
353
- ),
265
+ Set : _NS (_P ("list" )),
354
266
APIVersion : "v1" ,
355
267
},
356
268
},
357
269
},
358
- "apply_update_apply_with_overlap " : {
270
+ "apply_update_apply_list " : {
359
271
Ops : []Operation {
360
272
Apply {
361
273
Manager : "default" ,
@@ -377,7 +289,7 @@ func TestDeducedTypesBroken(t *testing.T) {
377
289
- d
378
290
` ,
379
291
},
380
- Apply {
292
+ ForceApply {
381
293
Manager : "default" ,
382
294
APIVersion : "v1" ,
383
295
Object : `
@@ -393,131 +305,40 @@ func TestDeducedTypesBroken(t *testing.T) {
393
305
- a
394
306
- b
395
307
- c
396
- - d
397
308
` ,
398
309
Managed : fieldpath.ManagedFields {
399
310
"default" : & fieldpath.VersionedSet {
400
- Set : _NS (
401
- _P ("list" , _SV ("a" )),
402
- _P ("list" , _SV ("b" )),
403
- _P ("list" , _SV ("c" )),
404
- ),
405
- APIVersion : "v1" ,
406
- },
407
- "controller" : & fieldpath.VersionedSet {
408
- Set : _NS (
409
- _P ("list" , _SV ("b" )),
410
- _P ("list" , _SV ("d" )),
411
- ),
412
- APIVersion : "v1" ,
413
- },
414
- },
415
- },
416
- "apply_twice_reorder" : {
417
- Ops : []Operation {
418
- Apply {
419
- Manager : "default" ,
420
- APIVersion : "v1" ,
421
- Object : `
422
- list:
423
- - a
424
- - b
425
- - c
426
- - d
427
- ` ,
428
- },
429
- Apply {
430
- Manager : "default" ,
431
- APIVersion : "v1" ,
432
- Object : `
433
- list:
434
- - a
435
- - d
436
- - c
437
- - b
438
- ` ,
439
- },
440
- },
441
- Object : `
442
- list:
443
- - a
444
- - d
445
- - c
446
- - b
447
- ` ,
448
- Managed : fieldpath.ManagedFields {
449
- "default" : & fieldpath.VersionedSet {
450
- Set : _NS (
451
- _P ("list" , _SV ("a" )),
452
- _P ("list" , _SV ("b" )),
453
- _P ("list" , _SV ("c" )),
454
- _P ("list" , _SV ("d" )),
455
- ),
311
+ Set : _NS (_P ("list" )),
456
312
APIVersion : "v1" ,
457
313
},
458
314
},
459
315
},
460
- "apply_update_apply_reorder " : {
316
+ "leaf_apply_remove_empty_set " : {
461
317
Ops : []Operation {
462
318
Apply {
463
319
Manager : "default" ,
464
320
APIVersion : "v1" ,
465
321
Object : `
466
- list:
467
- - a
468
- - b
469
- - c
470
- - d
471
- ` ,
472
- },
473
- Update {
474
- Manager : "controller" ,
475
- APIVersion : "v1" ,
476
- Object : `
477
- list:
478
- - a
479
- - d
480
- - c
481
- - b
322
+ string: "string"
482
323
` ,
483
324
},
484
325
Apply {
485
326
Manager : "default" ,
486
327
APIVersion : "v1" ,
487
- Object : `
488
- list:
489
- - a
490
- - b
491
- - c
492
- - d
493
- ` ,
328
+ Object : `` ,
494
329
},
495
330
},
496
331
Object : `
497
- list:
498
- - a
499
- - b
500
- - c
501
- - d
332
+ string: "string"
502
333
` ,
503
- Managed : fieldpath.ManagedFields {
504
- "default" : & fieldpath.VersionedSet {
505
- Set : _NS (
506
- _P ("list" , _SV ("a" )),
507
- _P ("list" , _SV ("b" )),
508
- _P ("list" , _SV ("c" )),
509
- _P ("list" , _SV ("d" )),
510
- ),
511
- APIVersion : "v1" ,
512
- },
513
- },
334
+ Managed : fieldpath.ManagedFields {},
514
335
},
515
336
}
516
337
517
338
for name , test := range tests {
518
339
t .Run (name , func (t * testing.T ) {
519
- if test .Test (typed.DeducedParseableType {}) = = nil {
520
- t .Fatal ("Broken test passed" )
340
+ if err := test .Test (typed.DeducedParseableType {}); err ! = nil {
341
+ t .Fatal (err )
521
342
}
522
343
})
523
344
}
0 commit comments