@@ -17,6 +17,7 @@ limitations under the License.
17
17
package endpointslicemirroring
18
18
19
19
import (
20
+ "sort"
20
21
"testing"
21
22
22
23
discovery "k8s.io/api/discovery/v1beta1"
@@ -50,8 +51,8 @@ func TestRecycleSlices(t *testing.T) {
50
51
},
51
52
expectedSlices : & slicesByAction {
52
53
toUpdate : []* discovery.EndpointSlice {
53
- simpleEndpointSlice ("baz" , "10.2.3.4" , discovery .AddressTypeIPv4 ),
54
54
simpleEndpointSlice ("bar" , "10.1.2.3" , discovery .AddressTypeIPv4 ),
55
+ simpleEndpointSlice ("baz" , "10.2.3.4" , discovery .AddressTypeIPv4 ),
55
56
},
56
57
},
57
58
}, {
@@ -122,11 +123,19 @@ func TestRecycleSlices(t *testing.T) {
122
123
123
124
for _ , tc := range testCases {
124
125
t .Run (tc .testName , func (t * testing.T ) {
125
- recycleSlices (tc .startingSlices )
126
+ startingSlices := tc .startingSlices
127
+ recycleSlices (startingSlices )
128
+
129
+ unorderedSlices := [][]* discovery.EndpointSlice {startingSlices .toCreate , startingSlices .toUpdate , startingSlices .toDelete }
130
+ for _ , actual := range unorderedSlices {
131
+ sort .Slice (actual , func (i , j int ) bool {
132
+ return actual [i ].Name < actual [j ].Name
133
+ })
134
+ }
126
135
127
- expectEqualSlices (t , tc . startingSlices .toCreate , tc .expectedSlices .toCreate )
128
- expectEqualSlices (t , tc . startingSlices .toUpdate , tc .expectedSlices .toUpdate )
129
- expectEqualSlices (t , tc . startingSlices .toDelete , tc .expectedSlices .toDelete )
136
+ expectEqualSlices (t , startingSlices .toCreate , tc .expectedSlices .toCreate )
137
+ expectEqualSlices (t , startingSlices .toUpdate , tc .expectedSlices .toUpdate )
138
+ expectEqualSlices (t , startingSlices .toDelete , tc .expectedSlices .toDelete )
130
139
})
131
140
}
132
141
}
0 commit comments