@@ -1144,11 +1144,10 @@ func TestSync_EmbeddedMapComparison_PointerVsValue_Success(t *testing.T) {
11441144 })
11451145}
11461146
1147- func TestSync_ArraySubset_Debug (t * testing.T ) {
1147+ func TestSync_ArraySubset_Success (t * testing.T ) {
11481148 t .Parallel ()
11491149
1150- // Create items for the high-level model (3 items - subset)
1151- // Source: items one, four, and six
1150+ // Create high-level model with 3 items
11521151 itemOne := & tests.TestItemHighModel {
11531152 Name : "one" ,
11541153 Description : "First item" ,
@@ -1166,9 +1165,7 @@ func TestSync_ArraySubset_Debug(t *testing.T) {
11661165 Items : []* tests.TestItemHighModel {itemOne , itemFour , itemSix },
11671166 }
11681167
1169- // Set the root node for the high-level model by creating a YAML node
1170- // This simulates the case where we have an existing YAML document with 6 items
1171- // Target: items three, five, one, four, second, and six (in this order)
1168+ // Populate core model with 6 items from YAML
11721169 initialYAML := `items:
11731170 - name: three
11741171 description: Third item
@@ -1187,18 +1184,13 @@ func TestSync_ArraySubset_Debug(t *testing.T) {
11871184 err := yaml .Unmarshal ([]byte (initialYAML ), & rootNode )
11881185 require .NoError (t , err )
11891186
1190- // Get the core model
11911187 coreModel := highModel .GetCore ()
1188+ coreModel .SetRootNode (rootNode .Content [0 ])
11921189
1193- // Set the root node on the core model (accessed through GetCore())
1194- coreModel .SetRootNode (rootNode .Content [0 ]) // Content[0] is the actual root mapping node
1195-
1196- // Unmarshal the YAML into the core model to populate it with the 6 items
11971190 _ , err = marshaller .UnmarshalModel (t .Context (), rootNode .Content [0 ], coreModel )
11981191 require .NoError (t , err )
11991192
1200- // Use SetCore to link each high-level item to its corresponding core item
1201- // This establishes the connection between high-level items and their core counterparts
1193+ // Link high-level items to their corresponding core items
12021194 for _ , item := range coreModel .Items .Value {
12031195 switch item .Name .Value {
12041196 case "one" :
@@ -1210,21 +1202,14 @@ func TestSync_ArraySubset_Debug(t *testing.T) {
12101202 }
12111203 }
12121204
1213- // Sync the high model (3 items) to the core model (currently 6 items)
1214- // This tests what happens when syncing a subset
1205+ // Sync high model subset to core model
12151206 resultNode , err := marshaller .SyncValue (t .Context (), & highModel , highModel .GetCore (), highModel .GetRootNode (), false )
12161207 require .NoError (t , err )
12171208 require .NotNil (t , resultNode )
12181209
1219- // Verify the synced array - should now match the high model's subset (3 items)
1220- // After sync, items two, three, five, and second should be removed
1210+ // Verify synced array matches high model subset
12211211 items := coreModel .Items .Value
1222- require .Len (t , items , 3 , "After sync, core model should have 3 items matching high model" )
1223-
1224- // Debug: Print what we actually got
1225- t .Logf ("Item 0: %s - %s" , items [0 ].Name .Value , items [0 ].Description .Value )
1226- t .Logf ("Item 1: %s - %s" , items [1 ].Name .Value , items [1 ].Description .Value )
1227- t .Logf ("Item 2: %s - %s" , items [2 ].Name .Value , items [2 ].Description .Value )
1212+ require .Len (t , items , 3 )
12281213
12291214 require .Equal (t , "one" , items [0 ].Name .Value )
12301215 require .Equal (t , "First item" , items [0 ].Description .Value )
@@ -1235,7 +1220,7 @@ func TestSync_ArraySubset_Debug(t *testing.T) {
12351220 require .Equal (t , "six" , items [2 ].Name .Value )
12361221 require .Equal (t , "Sixth item" , items [2 ].Description .Value )
12371222
1238- // Verify the core model's RootNode contains the correct YAML
1223+ // Verify YAML output
12391224 expectedYAML := `items:
12401225 - name: one
12411226 description: First item
0 commit comments