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.
50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
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)
|
|
}
|
|
}
|