diff --git a/internal/controller/status/prepare_requests.go b/internal/controller/status/prepare_requests.go index 4cb8fd5eab..f1909c1570 100644 --- a/internal/controller/status/prepare_requests.go +++ b/internal/controller/status/prepare_requests.go @@ -103,11 +103,11 @@ func removeDuplicateIndexParentRefs(parentRefs []graph.ParentRef) []graph.Parent idxToParentRef[ref.Idx] = append(idxToParentRef[ref.Idx], ref) } - results := make([]graph.ParentRef, len(idxToParentRef)) + results := make([]graph.ParentRef, 0, len(idxToParentRef)) for idx, refs := range idxToParentRef { if len(refs) == 1 { - results[idx] = refs[0] + results = append(results, refs[0]) continue } @@ -124,7 +124,7 @@ func removeDuplicateIndexParentRefs(parentRefs []graph.ParentRef) []graph.Parent } } } - results[idx] = winningParentRef + results = append(results, winningParentRef) } return results diff --git a/internal/controller/status/prepare_requests_test.go b/internal/controller/status/prepare_requests_test.go index 2480423d1e..f813f18335 100644 --- a/internal/controller/status/prepare_requests_test.go +++ b/internal/controller/status/prepare_requests_test.go @@ -445,7 +445,7 @@ func TestBuildHTTPRouteStatuses(t *testing.T) { err := k8sClient.Get(context.Background(), nsname, &hr) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(helpers.Diff(expected, hr.Status)).To(BeEmpty()) + g.Expect(expected.RouteStatus.Parents).To(ConsistOf(hr.Status.Parents)) } } @@ -524,7 +524,7 @@ func TestBuildGRPCRouteStatuses(t *testing.T) { err := k8sClient.Get(context.Background(), nsname, &hr) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(helpers.Diff(expected, hr.Status)).To(BeEmpty()) + g.Expect(expected.RouteStatus.Parents).To(ConsistOf(hr.Status.Parents)) } } @@ -601,7 +601,7 @@ func TestBuildTLSRouteStatuses(t *testing.T) { err := k8sClient.Get(context.Background(), nsname, &hr) g.Expect(err).ToNot(HaveOccurred()) - g.Expect(helpers.Diff(expected, hr.Status)).To(BeEmpty()) + g.Expect(expected.RouteStatus.Parents).To(ConsistOf(hr.Status.Parents)) } }