Skip to content

Commit 5579b6f

Browse files
committed
Adopt unit test to new API
1 parent 7123a8c commit 5579b6f

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

pkg/metricstore/healthcheck.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ func (l *Level) getHealthyMetrics(m *MemoryStore, expectedMetrics []string) []st
9595
continue
9696
}
9797

98-
if degraded[metricName] {
99-
degradedList = append(degradedList, metricName)
100-
}
98+
degradedList = append(degradedList, metricName)
10199
}
102100

103101
return degradedList

pkg/metricstore/metricstore_test.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -303,39 +303,35 @@ func TestGetHealthyMetrics(t *testing.T) {
303303
name string
304304
selector []string
305305
expectedMetrics []string
306-
wantMissing []string
307306
wantDegraded []string
308307
wantErr bool
309308
}{
310309
{
311310
name: "mixed health states",
312311
selector: []string{"testcluster", "testnode"},
313312
expectedMetrics: []string{"load", "mem_used", "cpu_user"},
314-
wantMissing: []string{"cpu_user"},
315-
wantDegraded: []string{"mem_used"},
313+
wantDegraded: []string{"mem_used", "cpu_user"},
316314
wantErr: false,
317315
},
318316
{
319317
name: "node not found",
320318
selector: []string{"testcluster", "nonexistent"},
321319
expectedMetrics: []string{"load"},
322-
wantMissing: nil,
323320
wantDegraded: nil,
324321
wantErr: true,
325322
},
326323
{
327324
name: "check only healthy metric",
328325
selector: []string{"testcluster", "testnode"},
329326
expectedMetrics: []string{"load"},
330-
wantMissing: []string{},
331327
wantDegraded: []string{},
332328
wantErr: false,
333329
},
334330
}
335331

336332
for _, tt := range tests {
337333
t.Run(tt.name, func(t *testing.T) {
338-
missing, degraded, err := ms.GetHealthyMetrics(tt.selector, tt.expectedMetrics)
334+
degraded, err := ms.GetHealthyMetrics(tt.selector, tt.expectedMetrics)
339335

340336
if (err != nil) != tt.wantErr {
341337
t.Errorf("GetHealthyMetrics() error = %v, wantErr %v", err, tt.wantErr)
@@ -346,17 +342,6 @@ func TestGetHealthyMetrics(t *testing.T) {
346342
return
347343
}
348344

349-
// Check missing list
350-
if len(missing) != len(tt.wantMissing) {
351-
t.Errorf("GetHealthyMetrics() missing = %v, want %v", missing, tt.wantMissing)
352-
} else {
353-
for i, m := range tt.wantMissing {
354-
if missing[i] != m {
355-
t.Errorf("GetHealthyMetrics() missing[%d] = %v, want %v", i, missing[i], m)
356-
}
357-
}
358-
}
359-
360345
// Check degraded list
361346
if len(degraded) != len(tt.wantDegraded) {
362347
t.Errorf("GetHealthyMetrics() degraded = %v, want %v", degraded, tt.wantDegraded)

0 commit comments

Comments
 (0)