Skip to content

Commit e71bab7

Browse files
committed
Show how null is inserted when struct is removed
1 parent f09efb3 commit e71bab7

File tree

1 file changed

+199
-0
lines changed

1 file changed

+199
-0
lines changed

merge/nested_test.go

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ var nestedTypeParser = func() Parser {
4444
- name: mapOfMapsRecursive
4545
type:
4646
namedType: mapOfMapsRecursive
47+
- name: struct
48+
type:
49+
namedType: struct
50+
- name: struct
51+
map:
52+
fields:
53+
- name: name
54+
type:
55+
scalar: string
56+
- name: value
57+
type:
58+
scalar: number
4759
- name: listOfLists
4860
list:
4961
elementType:
@@ -500,6 +512,193 @@ func TestUpdateNestedType(t *testing.T) {
500512
),
501513
},
502514
},
515+
"struct_apply_remove_all": {
516+
Ops: []Operation{
517+
Apply{
518+
Manager: "default",
519+
Object: `
520+
struct:
521+
name: a
522+
value: 1
523+
`,
524+
APIVersion: "v1",
525+
},
526+
Apply{
527+
Manager: "default",
528+
Object: `
529+
`,
530+
APIVersion: "v1",
531+
},
532+
},
533+
Object: `
534+
`,
535+
APIVersion: "v1",
536+
Managed: fieldpath.ManagedFields{},
537+
},
538+
"struct_apply_remove_dangling": {
539+
Ops: []Operation{
540+
Apply{
541+
Manager: "default",
542+
Object: `
543+
struct:
544+
name: a
545+
`,
546+
APIVersion: "v1",
547+
},
548+
Apply{
549+
Manager: "default",
550+
Object: `
551+
struct:
552+
`,
553+
APIVersion: "v1",
554+
},
555+
},
556+
Object: `
557+
struct:
558+
`,
559+
APIVersion: "v1",
560+
Managed: fieldpath.ManagedFields{
561+
"default": fieldpath.NewVersionedSet(
562+
_NS(
563+
_P("struct"),
564+
),
565+
"v1",
566+
true,
567+
),
568+
},
569+
},
570+
"struct_apply_update_remove_all": {
571+
Ops: []Operation{
572+
Apply{
573+
Manager: "default",
574+
Object: `
575+
struct:
576+
name: a
577+
`,
578+
APIVersion: "v1",
579+
},
580+
Update{
581+
Manager: "controller",
582+
Object: `
583+
struct:
584+
name: a
585+
value: 1
586+
`,
587+
APIVersion: "v1",
588+
},
589+
Apply{
590+
Manager: "default",
591+
Object: `
592+
`,
593+
APIVersion: "v1",
594+
},
595+
},
596+
Object: `
597+
struct:
598+
value: 1
599+
`,
600+
APIVersion: "v1",
601+
},
602+
"struct_apply_update_dict_dangling": {
603+
Ops: []Operation{
604+
Apply{
605+
Manager: "default",
606+
Object: `
607+
struct:
608+
name: a
609+
`,
610+
APIVersion: "v1",
611+
},
612+
Update{
613+
Manager: "controller",
614+
Object: `
615+
struct:
616+
name: a
617+
value: 1
618+
`,
619+
APIVersion: "v1",
620+
},
621+
Apply{
622+
Manager: "default",
623+
Object: `
624+
struct: {}
625+
`,
626+
APIVersion: "v1",
627+
},
628+
},
629+
Object: `
630+
struct:
631+
value: 1
632+
`,
633+
APIVersion: "v1",
634+
},
635+
"struct_apply_update_dict_null": {
636+
Ops: []Operation{
637+
Apply{
638+
Manager: "default",
639+
Object: `
640+
struct:
641+
name: a
642+
`,
643+
APIVersion: "v1",
644+
},
645+
Update{
646+
Manager: "controller",
647+
Object: `
648+
struct:
649+
name: a
650+
value: 1
651+
`,
652+
APIVersion: "v1",
653+
},
654+
Apply{
655+
Manager: "default",
656+
Object: `
657+
struct:
658+
`,
659+
APIVersion: "v1",
660+
},
661+
},
662+
Object: `
663+
struct:
664+
value: 1
665+
`,
666+
APIVersion: "v1",
667+
},
668+
"struct_apply_update_took_over": {
669+
Ops: []Operation{
670+
Apply{
671+
Manager: "default",
672+
Object: `
673+
struct:
674+
name: a
675+
`,
676+
APIVersion: "v1",
677+
},
678+
Update{
679+
Manager: "controller",
680+
Object: `
681+
struct:
682+
name: b
683+
value: 1
684+
`,
685+
APIVersion: "v1",
686+
},
687+
Apply{
688+
Manager: "default",
689+
Object: `
690+
struct:
691+
`,
692+
APIVersion: "v1",
693+
},
694+
},
695+
Object: `
696+
struct:
697+
name: b
698+
value: 1
699+
`,
700+
APIVersion: "v1",
701+
},
503702
}
504703

505704
for name, test := range tests {

0 commit comments

Comments
 (0)