From 114e8771af0e2027fef18aee1bab289431908869 Mon Sep 17 00:00:00 2001 From: Vadim Rutkovsky Date: Mon, 16 Mar 2026 09:57:43 +0100 Subject: [PATCH] test: avoid using ElementsMatch in unit tests --- .../operator/factory/reconcile/statefulset_pvc_expand_test.go | 2 +- .../operator/factory/vmalertmanager/alertmanager_test.go | 4 ++-- .../controller/operator/factory/vmsingle/vmsingle_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/controller/operator/factory/reconcile/statefulset_pvc_expand_test.go b/internal/controller/operator/factory/reconcile/statefulset_pvc_expand_test.go index 6014a529c..063ebcbd8 100644 --- a/internal/controller/operator/factory/reconcile/statefulset_pvc_expand_test.go +++ b/internal/controller/operator/factory/reconcile/statefulset_pvc_expand_test.go @@ -181,7 +181,7 @@ func Test_updateSTSPVC(t *testing.T) { LabelSelector: labels.SelectorFromSet(o.sts.Spec.Selector.MatchLabels), } assert.NoError(t, cl.List(ctx, &pvcs, listOpts)) - assert.ElementsMatch(t, o.expected, pvcs.Items) + assert.Equal(t, o.expected, pvcs.Items) } buildSTS := func(fns ...func(*appsv1.StatefulSet)) *appsv1.StatefulSet { diff --git a/internal/controller/operator/factory/vmalertmanager/alertmanager_test.go b/internal/controller/operator/factory/vmalertmanager/alertmanager_test.go index 9f077689e..ecc59bc48 100644 --- a/internal/controller/operator/factory/vmalertmanager/alertmanager_test.go +++ b/internal/controller/operator/factory/vmalertmanager/alertmanager_test.go @@ -190,7 +190,7 @@ func TestCreateOrUpdateAlertManager(t *testing.T) { } } - assert.ElementsMatch(t, clusterPeers, []string{ + assert.Equal(t, clusterPeers, []string{ "--cluster.peer=vmalertmanager-test-am-0.vmalertmanager-test-am.monitoring:9094", "--cluster.peer=vmalertmanager-test-am-1.vmalertmanager-test-am.monitoring:9094", "--cluster.peer=vmalertmanager-test-am-2.vmalertmanager-test-am.monitoring:9094", @@ -225,7 +225,7 @@ func TestCreateOrUpdateAlertManager(t *testing.T) { } } - assert.ElementsMatch(t, clusterPeers, []string{ + assert.Equal(t, clusterPeers, []string{ "--cluster.peer=vmalertmanager-test-am-0.vmalertmanager-test-am.monitoring.svc.example.com.:9094", "--cluster.peer=vmalertmanager-test-am-1.vmalertmanager-test-am.monitoring.svc.example.com.:9094", "--cluster.peer=vmalertmanager-test-am-2.vmalertmanager-test-am.monitoring.svc.example.com.:9094", diff --git a/internal/controller/operator/factory/vmsingle/vmsingle_test.go b/internal/controller/operator/factory/vmsingle/vmsingle_test.go index e56404041..4e681431d 100644 --- a/internal/controller/operator/factory/vmsingle/vmsingle_test.go +++ b/internal/controller/operator/factory/vmsingle/vmsingle_test.go @@ -102,7 +102,7 @@ func TestCreateOrUpdateService(t *testing.T) { } assert.NoError(t, fclient.Get(ctx, nsn, &got)) assert.Equal(t, got.Name, o.want.Name) - assert.ElementsMatch(t, got.Spec.Ports, o.want.Spec.Ports) + assert.Equal(t, got.Spec.Ports, o.want.Spec.Ports) } // base service test