shirou_gopsutil/disk_test.go

40 lines
633 B
Go
Raw Normal View History

2014-04-22 08:44:22 +08:00
package gopsutil
2014-04-18 15:34:47 +08:00
import (
2014-04-29 13:59:22 +08:00
// "fmt"
2014-04-19 23:03:47 +08:00
"runtime"
2014-04-18 15:34:47 +08:00
"testing"
)
func TestDisk_usage(t *testing.T) {
2014-04-19 23:03:47 +08:00
path := "/"
if runtime.GOOS == "windows" {
path = "C:"
}
2014-04-30 14:32:05 +08:00
_, err := DiskUsage(path)
2014-04-18 15:34:47 +08:00
if err != nil {
t.Errorf("error %v", err)
}
2014-04-29 13:59:22 +08:00
// d, _ := json.Marshal(v)
// fmt.Printf("%s\n", d)
2014-04-18 15:34:47 +08:00
}
2014-04-20 00:53:34 +08:00
func TestDisk_partitions(t *testing.T) {
2014-04-30 14:32:05 +08:00
_, err := DiskPartitions(false)
2014-04-20 00:53:34 +08:00
if err != nil {
t.Errorf("error %v", err)
}
}
2014-04-29 13:59:22 +08:00
func TestDisk_io_counters(t *testing.T) {
2014-04-30 14:32:05 +08:00
ret, err := DiskIOCounters()
2014-04-29 13:59:22 +08:00
if err != nil {
t.Errorf("error %v", err)
}
for _, io := range ret {
if io.Name == "" {
t.Errorf("io_counter error %v", io)
}
}
}