1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-28 13:48:49 +08:00
shirou_gopsutil/docker/docker_linux_test.go

59 lines
1.1 KiB
Go
Raw Normal View History

2014-06-10 14:38:01 +09:00
// +build linux
2014-12-30 22:09:05 +09:00
package docker
2014-06-10 14:38:01 +09:00
import "testing"
2014-06-10 14:38:01 +09:00
func TestGetDockerIDList(t *testing.T) {
// If there is not docker environment, this test always fail.
// not tested here
/*
2014-08-15 19:18:30 +02:00
_, err := GetDockerIDList()
if err != nil {
t.Errorf("error %v", err)
}
*/
2014-06-10 14:38:01 +09:00
}
func TestCgroupCPU(t *testing.T) {
v, _ := GetDockerIDList()
for _, id := range v {
v, err := CgroupCPUDocker(id)
if err != nil {
t.Errorf("error %v", err)
}
if v.CPU == "" {
t.Errorf("could not get CgroupCPU %v", v)
}
}
}
func TestCgroupCPUInvalidId(t *testing.T) {
_, err := CgroupCPUDocker("bad id")
if err == nil {
t.Error("Expected path does not exist error")
}
}
2014-06-10 14:38:01 +09:00
func TestCgroupMem(t *testing.T) {
v, _ := GetDockerIDList()
for _, id := range v {
v, err := CgroupMemDocker(id)
if err != nil {
t.Errorf("error %v", err)
}
empty := &CgroupMemStat{}
if v == empty {
t.Errorf("Could not CgroupMemStat %v", v)
}
}
}
func TestCgroupMemInvalidId(t *testing.T) {
_, err := CgroupMemDocker("bad id")
if err == nil {
t.Error("Expected path does not exist error")
}
}