From df23ecdf33132be255c120afafee4afca6724e0a Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Sat, 4 Jun 2022 09:42:45 -0700 Subject: [PATCH] fix typing for attribute status enum stored in database. --- .../pkg/models/measurements/smart_ata_attribute.go | 4 ++-- .../models/measurements/smart_nvme_attribute.go | 4 ++-- .../models/measurements/smart_scsci_attribute.go | 4 ++-- .../backend/pkg/models/measurements/smart_test.go | 14 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/webapp/backend/pkg/models/measurements/smart_ata_attribute.go b/webapp/backend/pkg/models/measurements/smart_ata_attribute.go index eac0913..8b9a3f4 100644 --- a/webapp/backend/pkg/models/measurements/smart_ata_attribute.go +++ b/webapp/backend/pkg/models/measurements/smart_ata_attribute.go @@ -43,7 +43,7 @@ func (sa *SmartAtaAttribute) Flatten() map[string]interface{} { //Generated Data fmt.Sprintf("attr.%s.transformed_value", idString): sa.TransformedValue, - fmt.Sprintf("attr.%s.status", idString): sa.Status, + fmt.Sprintf("attr.%s.status", idString): int64(sa.Status), fmt.Sprintf("attr.%s.status_reason", idString): sa.StatusReason, fmt.Sprintf("attr.%s.failure_rate", idString): sa.FailureRate, } @@ -77,7 +77,7 @@ func (sa *SmartAtaAttribute) Inflate(key string, val interface{}) { case "transformed_value": sa.TransformedValue = val.(int64) case "status": - sa.Status = val.(pkg.AttributeStatus) + sa.Status = pkg.AttributeStatus(val.(int64)) case "status_reason": sa.StatusReason = val.(string) case "failure_rate": diff --git a/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go b/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go index f4d314d..a2c58a1 100644 --- a/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go +++ b/webapp/backend/pkg/models/measurements/smart_nvme_attribute.go @@ -30,7 +30,7 @@ func (sa *SmartNvmeAttribute) Flatten() map[string]interface{} { //Generated Data fmt.Sprintf("attr.%s.transformed_value", sa.AttributeId): sa.TransformedValue, - fmt.Sprintf("attr.%s.status", sa.AttributeId): sa.Status, + fmt.Sprintf("attr.%s.status", sa.AttributeId): int64(sa.Status), fmt.Sprintf("attr.%s.status_reason", sa.AttributeId): sa.StatusReason, fmt.Sprintf("attr.%s.failure_rate", sa.AttributeId): sa.FailureRate, } @@ -54,7 +54,7 @@ func (sa *SmartNvmeAttribute) Inflate(key string, val interface{}) { case "transformed_value": sa.TransformedValue = val.(int64) case "status": - sa.Status = val.(pkg.AttributeStatus) + sa.Status = pkg.AttributeStatus(val.(int64)) case "status_reason": sa.StatusReason = val.(string) case "failure_rate": diff --git a/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go b/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go index 9b59f6b..4fd8a36 100644 --- a/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go +++ b/webapp/backend/pkg/models/measurements/smart_scsci_attribute.go @@ -30,7 +30,7 @@ func (sa *SmartScsiAttribute) Flatten() map[string]interface{} { //Generated Data fmt.Sprintf("attr.%s.transformed_value", sa.AttributeId): sa.TransformedValue, - fmt.Sprintf("attr.%s.status", sa.AttributeId): sa.Status, + fmt.Sprintf("attr.%s.status", sa.AttributeId): int64(sa.Status), fmt.Sprintf("attr.%s.status_reason", sa.AttributeId): sa.StatusReason, fmt.Sprintf("attr.%s.failure_rate", sa.AttributeId): sa.FailureRate, } @@ -54,7 +54,7 @@ func (sa *SmartScsiAttribute) Inflate(key string, val interface{}) { case "transformed_value": sa.TransformedValue = val.(int64) case "status": - sa.Status = val.(pkg.AttributeStatus) + sa.Status = pkg.AttributeStatus(val.(int64)) case "status_reason": sa.StatusReason = val.(string) case "failure_rate": diff --git a/webapp/backend/pkg/models/measurements/smart_test.go b/webapp/backend/pkg/models/measurements/smart_test.go index b7fdd18..ad7b73e 100644 --- a/webapp/backend/pkg/models/measurements/smart_test.go +++ b/webapp/backend/pkg/models/measurements/smart_test.go @@ -77,7 +77,7 @@ func TestSmart_Flatten_ATA(t *testing.T) { "attr.1.failure_rate": float64(0), "attr.1.raw_string": "0", "attr.1.raw_value": int64(0), - "attr.1.status": pkg.AttributeStatus(0), + "attr.1.status": int64(0), "attr.1.status_reason": "", "attr.1.thresh": int64(1), "attr.1.transformed_value": int64(0), @@ -89,7 +89,7 @@ func TestSmart_Flatten_ATA(t *testing.T) { "attr.2.failure_rate": float64(0), "attr.2.raw_string": "108", "attr.2.raw_value": int64(108), - "attr.2.status": pkg.AttributeStatus(0), + "attr.2.status": int64(0), "attr.2.status_reason": "", "attr.2.thresh": int64(54), "attr.2.transformed_value": int64(0), @@ -130,7 +130,7 @@ func TestSmart_Flatten_SCSI(t *testing.T) { require.Equal(t, map[string]interface{}{ "attr.read_errors_corrected_by_eccfast.attribute_id": "read_errors_corrected_by_eccfast", "attr.read_errors_corrected_by_eccfast.failure_rate": float64(0), - "attr.read_errors_corrected_by_eccfast.status": pkg.AttributeStatus(0), + "attr.read_errors_corrected_by_eccfast.status": int64(0), "attr.read_errors_corrected_by_eccfast.status_reason": "", "attr.read_errors_corrected_by_eccfast.thresh": int64(0), "attr.read_errors_corrected_by_eccfast.transformed_value": int64(0), @@ -168,7 +168,7 @@ func TestSmart_Flatten_NVMe(t *testing.T) { require.Equal(t, map[string]interface{}{ "attr.available_spare.attribute_id": "available_spare", "attr.available_spare.failure_rate": float64(0), - "attr.available_spare.status": pkg.AttributeStatus(0), + "attr.available_spare.status": int64(0), "attr.available_spare.status_reason": "", "attr.available_spare.thresh": int64(0), "attr.available_spare.transformed_value": int64(0), @@ -189,7 +189,7 @@ func TestNewSmartFromInfluxDB_ATA(t *testing.T) { "attr.1.failure_rate": float64(0), "attr.1.raw_string": "108", "attr.1.raw_value": int64(108), - "attr.1.status": pkg.AttributeStatus(0), + "attr.1.status": int64(0), "attr.1.status_reason": "", "attr.1.thresh": int64(54), "attr.1.transformed_value": int64(0), @@ -235,7 +235,7 @@ func TestNewSmartFromInfluxDB_NVMe(t *testing.T) { "device_protocol": pkg.DeviceProtocolNvme, "attr.available_spare.attribute_id": "available_spare", "attr.available_spare.failure_rate": float64(0), - "attr.available_spare.status": pkg.AttributeStatus(0), + "attr.available_spare.status": int64(0), "attr.available_spare.status_reason": "", "attr.available_spare.thresh": int64(0), "attr.available_spare.transformed_value": int64(0), @@ -274,7 +274,7 @@ func TestNewSmartFromInfluxDB_SCSI(t *testing.T) { "device_protocol": pkg.DeviceProtocolScsi, "attr.read_errors_corrected_by_eccfast.attribute_id": "read_errors_corrected_by_eccfast", "attr.read_errors_corrected_by_eccfast.failure_rate": float64(0), - "attr.read_errors_corrected_by_eccfast.status": pkg.AttributeStatus(0), + "attr.read_errors_corrected_by_eccfast.status": int64(0), "attr.read_errors_corrected_by_eccfast.status_reason": "", "attr.read_errors_corrected_by_eccfast.thresh": int64(0), "attr.read_errors_corrected_by_eccfast.transformed_value": int64(0),