2016-05-21 05:41:21 +00:00
|
|
|
package stats
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2016-05-21 06:16:24 +00:00
|
|
|
"time"
|
2016-05-21 05:41:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestCpuStatsPercent(t *testing.T) {
|
|
|
|
cs := NewCpuStats()
|
2016-05-21 06:16:24 +00:00
|
|
|
cs.Percent(79.7)
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
percent := cs.Percent(80.69)
|
|
|
|
expectedPercent := 98.00
|
|
|
|
if percent < expectedPercent && percent > (expectedPercent+1.00) {
|
|
|
|
t.Fatalf("expected: %v, actual: %v", expectedPercent, percent)
|
|
|
|
}
|
2016-05-21 05:41:21 +00:00
|
|
|
}
|