From 3fe1e91debba34b8fec9ebb9d25dd8ccf8d1d829 Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Mon, 10 Aug 2020 14:13:35 -0700 Subject: [PATCH] Add test for multiple appliers with atomic maps --- merge/multiple_appliers_test.go | 82 +++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/merge/multiple_appliers_test.go b/merge/multiple_appliers_test.go index fed31141..ae4706aa 100644 --- a/merge/multiple_appliers_test.go +++ b/merge/multiple_appliers_test.go @@ -1620,6 +1620,88 @@ func (r renamingConverter) IsMissingVersionError(err error) bool { return err == missingVersionError } +var atomicMapParser = func() Parser { + parser, err := typed.NewParser(`types: +- name: v1 + map: + fields: + - name: atomicMap + type: + namedType: atomicMap +- name: atomicMap + map: + fields: + - name: field1 + type: + scalar: string + - name: field2 + type: + scalar: string + elementRelationship: atomic +`) + if err != nil { + panic(err) + } + return parser +}() + +func TestMultipleApplierAtomicMaps(t *testing.T) { + tests := map[string]TestCase{ + "force": { + Ops: []Operation{ + Apply{ + Manager: "apply-one", + APIVersion: "v1", + Object: ` + atomicMap: + field1: a + `, + }, + Apply{ + Manager: "apply-two", + APIVersion: "v1", + Object: ` + atomicMap: + field2: b + `, + Conflicts: merge.Conflicts{ + merge.Conflict{Manager: "apply-one", Path: _P("atomicMap")}, + }, + }, + ForceApply{ + Manager: "apply-two", + APIVersion: "v1", + Object: ` + atomicMap: + field2: b + `, + }, + }, + Object: ` + atomicMap: + field2: b + `, + APIVersion: "v1", + Managed: fieldpath.ManagedFields{ + "apply-two": fieldpath.NewVersionedSet( + _NS( + _P("atomicMap"), + ), + "v1", + false, + ), + }, + }, + } + for name, test := range tests { + t.Run(name, func(t *testing.T) { + if err := test.Test(atomicMapParser); err != nil { + t.Fatal(err) + } + }) + } +} + func BenchmarkMultipleApplierRecursiveRealConversion(b *testing.B) { test := TestCase{ Ops: []Operation{