@@ -61,29 +61,22 @@ func TestCompare_ArrayAppendMultiple(t *testing.T) {
6161 o , err := overlay .Compare ("test" , & origNode , targetNode )
6262 require .NoError (t , err )
6363
64- // Should produce a single update action (no remove), appending the new elements
64+ // Emits a single append update for the new tail elements
6565 require .Len (t , o .Actions , 1 )
6666 assert .Equal (t , `$["items"]` , o .Actions [0 ].Target )
6767 assert .False (t , o .Actions [0 ].Remove )
68- assert .Equal (t , yaml .SequenceNode , o .Actions [0 ].Update .Kind )
6968 require .Len (t , o .Actions [0 ].Update .Content , 2 )
70- assert .Equal (t , "name: c\n " , nodeToString (t , o .Actions [0 ].Update .Content [0 ]))
71- assert .Equal (t , "name: d\n " , nodeToString (t , o .Actions [0 ].Update .Content [1 ]))
7269
7370 // Round-trip: applying the overlay should produce the target
7471 err = o .ApplyTo (& origNode )
7572 require .NoError (t , err )
76- var roundTripped yaml.Node
77- require .NoError (t , yaml .Unmarshal ([]byte (target ), & roundTripped ))
7873
79- origStr := nodeToString (t , & origNode )
80- targetStr := nodeToString (t , & roundTripped )
81- assert .Equal (t , targetStr , origStr )
82- }
74+ var expected yaml.Node
75+ require .NoError (t , yaml .Unmarshal ([]byte (target ), & expected ))
8376
84- func nodeToString ( t * testing. T , node * yaml.Node ) string {
85- t . Helper ( )
86- out , err := yaml .Marshal (node )
77+ actualYAML , err := yaml .Marshal ( & origNode )
78+ require . NoError ( t , err )
79+ expectedYAML , err := yaml .Marshal (& expected )
8780 require .NoError (t , err )
88- return string (out )
81+ assert . Equal ( t , string (expectedYAML ), string ( actualYAML ) )
8982}
0 commit comments