@@ -17,7 +17,6 @@ limitations under the License.
1717package merge_test
1818
1919import (
20- "reflect"
2120 "testing"
2221
2322 "sigs.k8s.io/structured-merge-diff/v4/fieldpath"
@@ -95,42 +94,21 @@ func TestToSet(t *testing.T) {
9594}
9695
9796func TestConflictsFromManagers (t * testing.T ) {
98- type args struct {
99- sets fieldpath.ManagedFields
100- }
101- tests := []struct {
102- name string
103- args args
104- want string
105- }{
106- {
107- name : "test with common prefix" ,
108- args : args {
109- sets : fieldpath.ManagedFields {
110- "Bob" : fieldpath .NewVersionedSet (
111- _NS (
112- _P ("spec" , "template" , "spec" , "containers" , _KBF ("name" , "probe" ), "livenessProbe" , "exec" , "command" ),
113- _P ("spec" , "template" , "spec" , "containers" , _KBF ("name" , "probe" ), "livenessProbe" , "periodSeconds" ),
114- _P ("spec" , "template" , "spec" , "containers" , _KBF ("name" , "probe" ), "readinessProbe" , "exec" , "command" ),
115- _P ("spec" , "template" , "spec" , "containers" , _KBF ("name" , "probe" ), "readinessProbe" , "periodSeconds" ),
116- ),
117- "v1" ,
118- false ,
119- ),
120- },
121- },
122- want : `conflicts with "Bob":
123- - .spec.template.spec.containers[name="probe"].livenessProbe.periodSeconds
124- - .spec.template.spec.containers[name="probe"].livenessProbe.exec.command
125- - .spec.template.spec.containers[name="probe"].readinessProbe.periodSeconds
126- - .spec.template.spec.containers[name="probe"].readinessProbe.exec.command` ,
127- },
128- }
129- for _ , tt := range tests {
130- t .Run (tt .name , func (t * testing.T ) {
131- if got := merge .ConflictsFromManagers (tt .args .sets ); ! reflect .DeepEqual (got .Error (), tt .want ) {
132- t .Errorf ("ConflictsFromManagers() = %v, want %v" , got , tt .want )
133- }
134- })
97+
98+ got := merge .ConflictsFromManagers (fieldpath.ManagedFields {
99+ "Bob" : fieldpath .NewVersionedSet (
100+ _NS (
101+ _P ("obj" , "template" , "obj" , "list" , _KBF ("name" , "a" ), "id" ),
102+ _P ("obj" , "template" , "obj" , "list" , _KBF ("name" , "a" ), "key" ),
103+ ),
104+ "v1" ,
105+ false ,
106+ ),
107+ })
108+ wanted := `conflicts with "Bob":
109+ - .obj.template.obj.list[name="a"].id
110+ - .obj.template.obj.list[name="a"].key`
111+ if got .Error () != wanted {
112+ t .Errorf ("Got %v, wanted %v" , got .Error (), wanted )
135113 }
136114}
0 commit comments