package main import ( "math" "testing" ) func TestCPUTemperatureSharedWithHistory(t *testing.T) { temperatures := []Temperature{{Label: "k10temp · Tctl", Celsius: 62}, {Label: "k10temp · Tccd1", Celsius: 38}, {Label: "k10temp · Tccd2", Celsius: 41}} live := cpuTemperature(temperatures) point := historyPointFromMetrics(dashboardMetrics{CPU: CPUMetrics{Temperatures: temperatures}}) if live == nil || *live != 62 || point.CPUTemperature != *live { t.Fatalf("live/history disagree: %v, %+v", live, point) } } func TestCPUTemperatureInvalidSensors(t *testing.T) { if cpuTemperature([]Temperature{{Celsius: math.NaN()}, {Celsius: math.Inf(1)}, {Celsius: 0}}) != nil { t.Fatal("invalid temperature selected") } if cpuTemperature(nil) != nil { t.Fatal("missing sensor should stay missing") } }