Skip to content

Commit

Permalink
Fix error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ikerreyes committed Nov 7, 2024
1 parent 64fba1f commit 20abf13
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion storage/dvo_recommendations_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,10 @@ func (storage DVORecommendationsDBStorage) ReadWorkloadsForClusterAndNamespace(

// filter report
var reportData []types.DVOWorkload
json.Unmarshal([]byte(dvoReport.Report), &reportData)
err = json.Unmarshal([]byte(dvoReport.Report), &reportData)
if err != nil {
return dvoReport, err
}

i := 0 // output index
for _, x := range reportData {
Expand Down
6 changes: 4 additions & 2 deletions storage/dvo_recommendations_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -829,8 +829,10 @@ func TestReadWorkloadsForClusterAndNamespace_HearbeatsFiltering(t *testing.T) {
helpers.FailOnError(t, err)

// write heartbeats
mockStorage.WriteHeartbeat("UID-0099", time.Now().UTC())
mockStorage.WriteHeartbeat("UID-0100", time.Now().UTC().Add(-1*time.Hour).UTC())
err = mockStorage.WriteHeartbeat("UID-0099", time.Now().UTC())
helpers.FailOnError(t, err)
err = mockStorage.WriteHeartbeat("UID-0100", time.Now().UTC().Add(-1*time.Hour).UTC())
helpers.FailOnError(t, err)

report, err := mockStorage.ReadWorkloadsForClusterAndNamespace(testdata.OrgID, testdata.ClusterName, "NAMESPACE-UID-A")
helpers.FailOnError(t, err)
Expand Down

0 comments on commit 20abf13

Please sign in to comment.