2014-04-22 08:44:22 +08:00
|
|
|
package gopsutil
|
2014-04-18 15:34:47 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"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) {
|
|
|
|
disk := NewDisk()
|
|
|
|
|
2014-04-19 23:03:47 +08:00
|
|
|
path := "/"
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
path = "C:"
|
|
|
|
}
|
|
|
|
v, err := disk.Disk_usage(path)
|
2014-04-18 15:34:47 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error %v", err)
|
|
|
|
}
|
|
|
|
d, _ := json.Marshal(v)
|
|
|
|
fmt.Printf("%s\n", d)
|
|
|
|
}
|
2014-04-20 00:53:34 +08:00
|
|
|
|
|
|
|
func TestDisk_partitions(t *testing.T) {
|
|
|
|
disk := NewDisk()
|
|
|
|
|
|
|
|
v, err := disk.Disk_partitions()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error %v", err)
|
|
|
|
}
|
|
|
|
d, _ := json.Marshal(v)
|
|
|
|
fmt.Printf("%s\n", d)
|
|
|
|
}
|