@@ -264,7 +264,7 @@ func TestWaitForResourcesToCleanUp(t *testing.T) {
264264 for name , tt := range tests {
265265 crp := & fleetv1beta1.ClusterResourcePlacement {}
266266 t .Run (name , func (t * testing.T ) {
267- gotWait , err := waitForResourcesToCleanUp (tt .allBindings , crp )
267+ gotWait , err := waitForResourcesToCleanUp (controller . ConvertCRBArrayToBindingObjs ( tt .allBindings ) , crp )
268268 if (err != nil ) != tt .wantErr {
269269 t .Errorf ("waitForResourcesToCleanUp test `%s` error = %v, wantErr %v" , name , err , tt .wantErr )
270270 return
@@ -618,7 +618,7 @@ func TestUpdateBindings(t *testing.T) {
618618 }
619619 if tt .desiredBindingsSpec != nil {
620620 inputs [i ].desiredBinding = tt .bindings [i ].DeepCopy ()
621- inputs [i ].desiredBinding .Spec = tt .desiredBindingsSpec [i ]
621+ inputs [i ].desiredBinding .SetBindingSpec ( tt .desiredBindingsSpec [i ])
622622 }
623623 }
624624 err := r .updateBindings (ctx , inputs )
@@ -2172,7 +2172,7 @@ func TestPickBindingsToRoll(t *testing.T) {
21722172 Name : tt .latestResourceSnapshotName ,
21732173 },
21742174 }
2175- gotUpdatedBindings , gotStaleUnselectedBindings , gotUpToDateBoundBindings , gotNeedRoll , gotWaitTime , err := r .pickBindingsToRoll (context .Background (), tt .allBindings , resourceSnapshot , tt .crp , tt .matchedCROs , tt .matchedROs )
2175+ gotUpdatedBindings , gotStaleUnselectedBindings , gotUpToDateBoundBindings , gotNeedRoll , gotWaitTime , err := r .pickBindingsToRoll (context .Background (), controller . ConvertCRBArrayToBindingObjs ( tt .allBindings ) , resourceSnapshot , tt .crp , tt .matchedCROs , tt .matchedROs )
21762176 if (err != nil ) != (tt .wantErr != nil ) || err != nil && ! errors .Is (err , tt .wantErr ) {
21772177 t .Fatalf ("pickBindingsToRoll() error = %v, wantErr %v" , err , tt .wantErr )
21782178 }
@@ -2183,21 +2183,23 @@ func TestPickBindingsToRoll(t *testing.T) {
21832183 wantTobeUpdatedBindings := make ([]toBeUpdatedBinding , len (tt .wantTobeUpdatedBindings ))
21842184 for i , index := range tt .wantTobeUpdatedBindings {
21852185 // Unscheduled bindings are only removed in a single rollout cycle.
2186- if tt .allBindings [index ].Spec .State != fleetv1beta1 .BindingStateUnscheduled {
2186+ bindingSpec := tt .allBindings [index ].GetBindingSpec ()
2187+ if bindingSpec .State != fleetv1beta1 .BindingStateUnscheduled {
21872188 wantTobeUpdatedBindings [i ].currentBinding = tt .allBindings [index ]
21882189 wantTobeUpdatedBindings [i ].desiredBinding = tt .allBindings [index ].DeepCopy ()
2189- wantTobeUpdatedBindings [i ].desiredBinding .Spec = tt .wantDesiredBindingsSpec [index ]
2190+ wantTobeUpdatedBindings [i ].desiredBinding .SetBindingSpec ( tt .wantDesiredBindingsSpec [index ])
21902191 } else {
21912192 wantTobeUpdatedBindings [i ].currentBinding = tt .allBindings [index ]
21922193 }
21932194 }
21942195 wantStaleUnselectedBindings := make ([]toBeUpdatedBinding , len (tt .wantStaleUnselectedBindings ))
21952196 for i , index := range tt .wantStaleUnselectedBindings {
21962197 // Unscheduled bindings are only removed in a single rollout cycle.
2197- if tt .allBindings [index ].Spec .State != fleetv1beta1 .BindingStateUnscheduled {
2198+ bindingSpec := tt .allBindings [index ].GetBindingSpec ()
2199+ if bindingSpec .State != fleetv1beta1 .BindingStateUnscheduled {
21982200 wantStaleUnselectedBindings [i ].currentBinding = tt .allBindings [index ]
21992201 wantStaleUnselectedBindings [i ].desiredBinding = tt .allBindings [index ].DeepCopy ()
2200- wantStaleUnselectedBindings [i ].desiredBinding .Spec = tt .wantDesiredBindingsSpec [index ]
2202+ wantStaleUnselectedBindings [i ].desiredBinding .SetBindingSpec ( tt .wantDesiredBindingsSpec [index ])
22012203 } else {
22022204 wantStaleUnselectedBindings [i ].currentBinding = tt .allBindings [index ]
22032205 }
@@ -2892,7 +2894,7 @@ func TestCheckAndUpdateStaleBindingsStatus(t *testing.T) {
28922894 Client : fakeClient ,
28932895 }
28942896 ctx := context .Background ()
2895- if err := r .checkAndUpdateStaleBindingsStatus (ctx , tt .bindings ); err != nil {
2897+ if err := r .checkAndUpdateStaleBindingsStatus (ctx , controller . ConvertCRBArrayToBindingObjs ( tt .bindings ) ); err != nil {
28962898 t .Fatalf ("checkAndUpdateStaleBindingsStatus() got error %v, want no err" , err )
28972899 }
28982900 bindingList := & fleetv1beta1.ClusterResourceBindingList {}
@@ -3168,7 +3170,7 @@ func TestProcessApplyStrategyUpdates(t *testing.T) {
31683170 Client : fakeClient ,
31693171 }
31703172
3171- applyStrategyUpdated , err := r .processApplyStrategyUpdates (ctx , tc .crp , tc .allBindings )
3173+ applyStrategyUpdated , err := r .processApplyStrategyUpdates (ctx , tc .crp , controller . ConvertCRBArrayToBindingObjs ( tc .allBindings ) )
31723174 if err != nil {
31733175 t .Errorf ("processApplyStrategyUpdates() error = %v, want no error" , err )
31743176 }
0 commit comments