github.com/bigcommerce/nomad@v0.9.3-bc/client/stats/host_test.go (about) 1 package stats 2 3 import ( 4 "testing" 5 6 "github.com/shirou/gopsutil/cpu" 7 ) 8 9 func TestHostCpuStatsCalculator_Nan(t *testing.T) { 10 times := cpu.TimesStat{ 11 User: 0.0, 12 Idle: 100.0, 13 System: 0.0, 14 } 15 16 calculator := NewHostCpuStatsCalculator() 17 calculator.Calculate(times) 18 idle, user, system, total := calculator.Calculate(times) 19 20 if idle != 100.0 { 21 t.Errorf("idle: Expected: %f, Got %f", 100.0, idle) 22 } 23 if user != 0.0 { 24 t.Errorf("user: Expected: %f, Got %f", 0.0, user) 25 } 26 if system != 0.0 { 27 t.Errorf("system: Expected: %f, Got %f", 0.0, system) 28 } 29 if total != 0.0 { 30 t.Errorf("total: Expected: %f, Got %f", 0.0, total) 31 } 32 }