Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This assertion makes the test depend on client.List returning PVCs in a specific order, which is not guaranteed. The behavior under test already sorts internally; the verification list should stay order-insensitive.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At internal/controller/operator/factory/reconcile/statefulset_pvc_expand_test.go, line 184:

<comment>This assertion makes the test depend on `client.List` returning PVCs in a specific order, which is not guaranteed. The behavior under test already sorts internally; the verification list should stay order-insensitive.</comment>

<file context>
@@ -181,7 +181,7 @@ func Test_updateSTSPVC(t *testing.T) {
 		}
 		assert.NoError(t, cl.List(ctx, &pvcs, listOpts))
-		assert.ElementsMatch(t, o.expected, pvcs.Items)
+		assert.Equal(t, o.expected, pvcs.Items)
 	}
 
</file context>
Suggested change
assert.Equal(t, o.expected, pvcs.Items)
assert.ElementsMatch(t, o.expected, pvcs.Items)
Fix with Cubic

}

buildSTS := func(fns ...func(*appsv1.StatefulSet)) *appsv1.StatefulSet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading