Separate network faults from software drops and fix CPU temperature history
This commit is contained in:
24
cpu_temperature_test.go
Normal file
24
cpu_temperature_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user