Skip to content

Commit 002f36a

Browse files
committed
Fix int value expected
1 parent 0ea9bbd commit 002f36a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

golden/file.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,19 @@ func valuesAreEqual(config Config, key string, output, expected any) error {
429429
}
430430

431431
if outputInt, IsInt := output.(int); IsInt {
432+
expectedFloat, expectedIsFloat := expected.(float64) // JSON unmarshals numbers as float64
432433
expectedInt, expectedIsInt := expected.(int)
433-
if !expectedIsInt {
434+
if !expectedIsInt && !expectedIsFloat {
434435
return fmt.Errorf(
435-
"key \"%s\": output value %v is int, expected value %v is not",
436+
"key \"%s\": output value %v is int, expected value %v is not float64 (JSON unmarshals numbers as float64)",
436437
key, outputInt, expected,
437438
)
438439
}
439440

441+
if expectedIsFloat {
442+
expectedInt = int(expectedFloat)
443+
}
444+
440445
threshold := config.Thresholds.Int
441446
if customThreshold, ok := config.Thresholds.CustomThresholds.Int[key]; ok {
442447
threshold = customThreshold

0 commit comments

Comments
 (0)