2014-12-30 21:09:05 +08:00
|
|
|
package load
|
2014-04-18 15:34:47 +08:00
|
|
|
|
|
|
|
import (
|
2014-05-12 10:51:08 +08:00
|
|
|
"fmt"
|
2014-04-18 15:34:47 +08:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLoad(t *testing.T) {
|
2014-05-23 09:31:47 +08:00
|
|
|
v, err := LoadAvg()
|
2014-04-18 15:34:47 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error %v", err)
|
|
|
|
}
|
|
|
|
|
2014-05-23 09:31:47 +08:00
|
|
|
empty := &LoadAvgStat{}
|
2014-05-12 10:51:08 +08:00
|
|
|
if v == empty {
|
2014-04-18 15:34:47 +08:00
|
|
|
t.Errorf("error load: %v", v)
|
|
|
|
}
|
|
|
|
}
|
2014-05-12 10:51:08 +08:00
|
|
|
|
|
|
|
func TestLoadAvgStat_String(t *testing.T) {
|
2014-05-23 09:31:47 +08:00
|
|
|
v := LoadAvgStat{
|
2014-05-12 10:51:08 +08:00
|
|
|
Load1: 10.1,
|
|
|
|
Load5: 20.1,
|
|
|
|
Load15: 30.1,
|
|
|
|
}
|
|
|
|
e := `{"load1":10.1,"load5":20.1,"load15":30.1}`
|
|
|
|
if e != fmt.Sprintf("%v", v) {
|
|
|
|
t.Errorf("LoadAvgStat string is invalid: %v", v)
|
|
|
|
}
|
|
|
|
}
|