From 46b51f833c54624a44b51d29cc3ebe18c061bf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= Date: Thu, 20 Jun 2024 15:23:19 +0200 Subject: [PATCH 1/3] Remove Strings as perfdata values --- perfdata/type.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/perfdata/type.go b/perfdata/type.go index 4814208..dc9202e 100644 --- a/perfdata/type.go +++ b/perfdata/type.go @@ -43,8 +43,6 @@ func formatNumeric(value interface{}) (string, error) { return check.FormatFloat(float64(v)), nil case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64: return fmt.Sprintf("%d", v), nil - case fmt.Stringer, string: - return fmt.Sprint(v), nil default: panic(fmt.Sprintf("unsupported type for perfdata: %T", value)) } From 3bdec50f0ef1deff4378364b23ae8360dc4cc6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= Date: Thu, 20 Jun 2024 15:32:47 +0200 Subject: [PATCH 2/3] Use float64 specifically in test case to cover that base --- perfdata/type_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perfdata/type_test.go b/perfdata/type_test.go index 6168df3..c656a69 100644 --- a/perfdata/type_test.go +++ b/perfdata/type_test.go @@ -123,7 +123,7 @@ func TestFormatNumeric(t *testing.T) { }, { Result: "1234.567", - InputValue: 1234.567, + InputValue: float64(1234.567), }, { Result: "1234.567", From e1ee1f8d2d20f8f4f2dfed4bf56cf82d63dd109c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20K=C3=A4stle?= Date: Thu, 20 Jun 2024 15:33:35 +0200 Subject: [PATCH 3/3] Remove string testcase and make the other easier to pick apart --- perfdata/type_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/perfdata/type_test.go b/perfdata/type_test.go index c656a69..5eff5e3 100644 --- a/perfdata/type_test.go +++ b/perfdata/type_test.go @@ -126,11 +126,8 @@ func TestFormatNumeric(t *testing.T) { InputValue: float64(1234.567), }, { - Result: "1234.567", - InputValue: float32(1234.567), - }, - {Result: "1234.567", - InputValue: "1234.567", + Result: "3456.789", + InputValue: float32(3456.789), }, { Result: "1234567890.988",