Skip to content

Commit

Permalink
Formatted file
Browse files Browse the repository at this point in the history
  • Loading branch information
ikerreyes committed Nov 13, 2024
1 parent 6f89c4f commit 1445631
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions storage/dvo_recommendations_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,55 +843,53 @@ func TestReadWorkloadsForClusterAndNamespace_HearbeatsFiltering(t *testing.T) {
assert.NotContains(t, report.Report, "UID-0100")
}


func NewDVOWorkload(uid string) types.DVOWorkload {
return types.DVOWorkload{
UID: uid,
}
}


func TestFilterWorkloads(t *testing.T) {

Check failure on line 852 in storage/dvo_recommendations_storage_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)

aliveInstances := map[string]bool{"x": true, "y": true, "z": true}

testCases := []struct{
testCases := []struct {
workloads []types.DVOWorkload
seen []string
seen []string
}{
{
workloads: []types.DVOWorkload{NewDVOWorkload("x")},
seen: []string{"x"},
seen: []string{"x"},
},
{
workloads: []types.DVOWorkload{NewDVOWorkload("a")},
seen: []string{},
seen: []string{},
},
{
workloads: []types.DVOWorkload{NewDVOWorkload("a"), NewDVOWorkload("x")},
seen: []string{"x"},
seen: []string{"x"},
},
{
workloads: []types.DVOWorkload{NewDVOWorkload("a"), NewDVOWorkload("x"), NewDVOWorkload("b"), NewDVOWorkload("y")},
seen: []string{"x", "y"},
seen: []string{"x", "y"},
},
}

for i, tt := range testCases {
t.Run("case-" + fmt.Sprint(i), func(t *testing.T) {
t.Run("case-"+fmt.Sprint(i), func(t *testing.T) {
gotSeen := map[string]bool{}
expectedSeen := map[string]bool{}
for _, v := range tt.seen {
expectedSeen[v] = true
}
got := storage.FilterWorkloads(tt.workloads, aliveInstances, gotSeen)

if reflect.DeepEqual(expectedSeen, gotSeen) {
t.Errorf("Seen objects error got = %v, want %v", gotSeen, expectedSeen)
}
assert.Len(t, got, len(tt.seen))
gotUIDs := []string{}
for _, workload := range got{
for _, workload := range got {
gotUIDs = append(gotUIDs, workload.UID)
}
assert.Equal(t, tt.seen, gotUIDs)
Expand Down

0 comments on commit 1445631

Please sign in to comment.