Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

test: Add edge case tests for coerceUint64 function

rcourtman1e9fbdfdcc7a
diff --git a/pkg/proxmox/client_test.go b/pkg/proxmox/client_test.go
index 6c0e435565..765113d139 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",