Expand test coverage across server, agent, and web; fix bugs found during audit.

Adds hundreds of unit/integration/e2e tests, fixes WS bcrypt auth, config merge, fleet analytics, agent schedule/log tail, and documents stale PROBLEMS items. Updates PROBLEMS.md, README, and test scripts; ignores local spread-kits and coverage dirs.
This commit is contained in:
AetherForge
2026-05-31 01:13:49 -07:00
parent 159747877c
commit ea6f54ad03
89 changed files with 5307 additions and 322 deletions

View File

@@ -0,0 +1,14 @@
//go:build linux
package stats
import "testing"
func TestParseKB(t *testing.T) {
if got := parseKB("MemTotal: 16384000 kB"); got != 16384000 {
t.Fatalf("got %d", got)
}
if parseKB("short") != 0 {
t.Fatal("invalid line should return 0")
}
}

View File

@@ -0,0 +1,49 @@
package stats
import (
"runtime"
"testing"
)
func TestNewReporterSystemInfo(t *testing.T) {
r := NewReporter()
host, cores, memGB := r.SystemInfo()
if host == "" {
t.Fatal("hostname should not be empty")
}
if cores < 1 {
t.Fatalf("cores %d", cores)
}
if memGB < 1 {
t.Fatalf("memoryGB %d", memGB)
}
}
func TestReporterUsage(t *testing.T) {
r := NewReporter()
cpu, mem := r.Usage()
if cpu < 0 || mem < 0 || mem > 100 {
t.Fatalf("cpu=%v mem=%v", cpu, mem)
}
}
func TestReporterMemoryMB(t *testing.T) {
r := NewReporter()
total := r.TotalMemoryMB()
free := r.FreeMemoryMB()
if runtime.GOOS == "windows" || runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
if total == 0 {
t.Fatal("expected non-zero total memory on supported platform")
}
}
if free > total && total > 0 {
t.Fatalf("free %d > total %d", free, total)
}
}
func TestReporterSystemCPUPercentNonNegative(t *testing.T) {
r := NewReporter()
if pct := r.SystemCPUPercent(); pct < 0 {
t.Fatalf("negative cpu percent: %v", pct)
}
}