From 002f36a342d6ba6745b2c6442f58fdb047797e74 Mon Sep 17 00:00:00 2001 From: Marius Merschformann Date: Thu, 19 Dec 2024 10:12:27 +0100 Subject: [PATCH] Fix int value expected --- golden/file.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/golden/file.go b/golden/file.go index 33d131ea..acf5f29a 100644 --- a/golden/file.go +++ b/golden/file.go @@ -429,14 +429,19 @@ func valuesAreEqual(config Config, key string, output, expected any) error { } if outputInt, IsInt := output.(int); IsInt { + expectedFloat, expectedIsFloat := expected.(float64) // JSON unmarshals numbers as float64 expectedInt, expectedIsInt := expected.(int) - if !expectedIsInt { + if !expectedIsInt && !expectedIsFloat { return fmt.Errorf( - "key \"%s\": output value %v is int, expected value %v is not", + "key \"%s\": output value %v is int, expected value %v is not float64 (JSON unmarshals numbers as float64)", key, outputInt, expected, ) } + if expectedIsFloat { + expectedInt = int(expectedFloat) + } + threshold := config.Thresholds.Int if customThreshold, ok := config.Thresholds.CustomThresholds.Int[key]; ok { threshold = customThreshold