Initial Proxmox dashboard with host and guest metrics

This commit is contained in:
maxim
2026-07-31 19:51:22 +03:00
commit 584ff7e8ee
21 changed files with 1780 additions and 0 deletions

59
main_test.go Normal file
View File

@@ -0,0 +1,59 @@
package main
import (
"os"
"path/filepath"
"testing"
)
func TestCPUModel(t *testing.T) {
path := filepath.Join(t.TempDir(), "cpuinfo")
content := `processor : 0
model name : Test CPU 1234 @ 2.40GHz
physical id : 0
core id : 0
processor : 1
model name : Test CPU 1234 @ 2.40GHz
physical id : 0
core id : 0
`
if err := os.WriteFile(path, []byte(content), 0o600); err != nil {
t.Fatal(err)
}
model, err := cpuModel(path)
if err != nil {
t.Fatal(err)
}
if model != "Test CPU 1234 @ 2.40GHz" {
t.Fatalf("получена неожиданная модель CPU: %q", model)
}
}
func TestCPUStatic(t *testing.T) {
path := filepath.Join(t.TempDir(), "cpuinfo")
content := `processor : 0
model name : Test CPU
physical id : 0
core id : 0
processor : 1
model name : Test CPU
physical id : 0
core id : 1
`
if err := os.WriteFile(path, []byte(content), 0o600); err != nil {
t.Fatal(err)
}
info, err := readCPUStatic(path)
if err != nil {
t.Fatal(err)
}
if info.Sockets != 1 || info.PhysicalCores != 2 || info.LogicalCPUs != 2 {
t.Fatalf("неожиданная топология CPU: %+v", info)
}
}