Skip to content

Commit e5b08bc

Browse files
committed
fix lint
Signed-off-by: Joseph Heyburn <jdheyburn@gmail.com>
1 parent 85c0d0f commit e5b08bc

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

internal/controller/metrics_test.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,24 @@ import (
2525
valkeyiov1alpha1 "github.com/valkey-io/valkey-operator/api/v1alpha1"
2626
)
2727

28-
func conditionGaugeValue(t *testing.T, name, ns, condType, status string) float64 {
28+
// testNamespace is the namespace used by all metrics tests.
29+
const testNamespace = "default"
30+
31+
func conditionGaugeValue(t *testing.T, name, condType, status string) float64 {
2932
t.Helper()
30-
return testutil.ToFloat64(clusterCondition.WithLabelValues(name, ns, condType, status))
33+
return testutil.ToFloat64(clusterCondition.WithLabelValues(name, testNamespace, condType, status))
3134
}
3235

3336
// expectConditionSeries asserts the three status series for a condition type.
34-
func expectConditionSeries(t *testing.T, name, ns, condType string, wantTrue, wantFalse, wantUnknown float64) {
37+
func expectConditionSeries(t *testing.T, name, condType string, wantTrue, wantFalse, wantUnknown float64) {
3538
t.Helper()
36-
if got := conditionGaugeValue(t, name, ns, condType, "true"); got != wantTrue {
39+
if got := conditionGaugeValue(t, name, condType, "true"); got != wantTrue {
3740
t.Errorf("%s{status=true} = %v, want %v", condType, got, wantTrue)
3841
}
39-
if got := conditionGaugeValue(t, name, ns, condType, "false"); got != wantFalse {
42+
if got := conditionGaugeValue(t, name, condType, "false"); got != wantFalse {
4043
t.Errorf("%s{status=false} = %v, want %v", condType, got, wantFalse)
4144
}
42-
if got := conditionGaugeValue(t, name, ns, condType, "unknown"); got != wantUnknown {
45+
if got := conditionGaugeValue(t, name, condType, "unknown"); got != wantUnknown {
4346
t.Errorf("%s{status=unknown} = %v, want %v", condType, got, wantUnknown)
4447
}
4548
}
@@ -72,24 +75,24 @@ func TestUpdateClusterMetrics_ClusterCondition(t *testing.T) {
7275

7376
// Condition absent -> all three status series read 0.
7477
updateClusterMetrics(cluster)
75-
expectConditionSeries(t, name, ns, condType, 0, 0, 0)
78+
expectConditionSeries(t, name, condType, 0, 0, 0)
7679

7780
setCondition(cluster, condType, valkeyiov1alpha1.ReasonAllPodsScheduled, "ok", metav1.ConditionTrue)
7881
updateClusterMetrics(cluster)
79-
expectConditionSeries(t, name, ns, condType, 1, 0, 0)
82+
expectConditionSeries(t, name, condType, 1, 0, 0)
8083

8184
setCondition(cluster, condType, valkeyiov1alpha1.ReasonPodsPendingScheduling, "pending", metav1.ConditionFalse)
8285
updateClusterMetrics(cluster)
83-
expectConditionSeries(t, name, ns, condType, 0, 1, 0)
86+
expectConditionSeries(t, name, condType, 0, 1, 0)
8487

8588
setCondition(cluster, condType, valkeyiov1alpha1.ReasonPodsPendingScheduling, "unknown", metav1.ConditionUnknown)
8689
updateClusterMetrics(cluster)
87-
expectConditionSeries(t, name, ns, condType, 0, 0, 1)
90+
expectConditionSeries(t, name, condType, 0, 0, 1)
8891

8992
// Condition removed again -> back to all zeros.
9093
cluster.Status.Conditions = nil
9194
updateClusterMetrics(cluster)
92-
expectConditionSeries(t, name, ns, condType, 0, 0, 0)
95+
expectConditionSeries(t, name, condType, 0, 0, 0)
9396
}
9497

9598
func TestUpdateClusterMetrics_UnregisteredConditionType(t *testing.T) {
@@ -104,5 +107,5 @@ func TestUpdateClusterMetrics_UnregisteredConditionType(t *testing.T) {
104107
setCondition(cluster, condType, "SomeReason", "some message", metav1.ConditionTrue)
105108

106109
updateClusterMetrics(cluster)
107-
expectConditionSeries(t, name, ns, condType, 1, 0, 0)
110+
expectConditionSeries(t, name, condType, 1, 0, 0)
108111
}

0 commit comments

Comments
 (0)