From 1e9fbdfdcc7ae8977aa90e1f71ace6fc0204bd3b Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 1 Dec 2025 22:36:03 +0000 Subject: [PATCH] test: Add edge case tests for coerceUint64 function Add 6 new test cases covering previously untested branches: - float64 at MaxUint64 boundary (clamping behavior) - float64 exceeding MaxUint64 (overflow protection) - String with quoted "null" value - String with quoted empty value ("") - String with single quoted empty value ('') - Invalid float parsing in scientific notation Coverage improved from 92.3% to 97.4%. --- pkg/proxmox/client_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pkg/proxmox/client_test.go b/pkg/proxmox/client_test.go index 6c0e43556..765113d13 100644 --- a/pkg/proxmox/client_test.go +++ b/pkg/proxmox/client_test.go @@ -603,6 +603,42 @@ func TestCoerceUint64(t *testing.T) { value: "not a number", wantErr: true, }, + { + name: "string invalid float in scientific notation", + field: "test", + value: "1.2.3e4", + wantErr: true, + }, + { + name: "string quoted null", + field: "test", + value: `"null"`, + want: 0, + }, + { + name: "string quoted empty", + field: "test", + value: `""`, + want: 0, + }, + { + name: "string single quoted empty", + field: "test", + value: `''`, + want: 0, + }, + { + name: "float64 at MaxUint64 boundary", + field: "test", + value: float64(math.MaxUint64), + want: math.MaxUint64, + }, + { + name: "float64 exceeding MaxUint64", + field: "test", + value: float64(math.MaxUint64) * 2, + want: math.MaxUint64, + }, // unsupported type { name: "unsupported type bool",