github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/client/stats/cpu_test.go (about) 1 package stats 2 3 import ( 4 "testing" 5 "time" 6 ) 7 8 func TestCpuStatsPercent(t *testing.T) { 9 cs := NewCpuStats() 10 cs.Percent(79.7) 11 time.Sleep(1 * time.Second) 12 percent := cs.Percent(80.69) 13 expectedPercent := 98.00 14 if percent < expectedPercent && percent > (expectedPercent+1.00) { 15 t.Fatalf("expected: %v, actual: %v", expectedPercent, percent) 16 } 17 }