[disk] Skip tests on non-implemented platforms #446

pull/928/head
Lomanic 5 years ago
parent 38f6ed0e0c
commit b7781f5858

@ -5,14 +5,23 @@ import (
"runtime" "runtime"
"sync" "sync"
"testing" "testing"
"github.com/shirou/gopsutil/internal/common"
) )
func skipIfNotImplementedErr(t *testing.T, err error) {
if err == common.ErrNotImplementedError {
t.Skip("not implemented")
}
}
func TestDisk_usage(t *testing.T) { func TestDisk_usage(t *testing.T) {
path := "/" path := "/"
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
path = "C:" path = "C:"
} }
v, err := Usage(path) v, err := Usage(path)
skipIfNotImplementedErr(t, err)
if err != nil { if err != nil {
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }
@ -23,6 +32,7 @@ func TestDisk_usage(t *testing.T) {
func TestDisk_partitions(t *testing.T) { func TestDisk_partitions(t *testing.T) {
ret, err := Partitions(false) ret, err := Partitions(false)
skipIfNotImplementedErr(t, err)
if err != nil || len(ret) == 0 { if err != nil || len(ret) == 0 {
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }
@ -41,6 +51,7 @@ func TestDisk_partitions(t *testing.T) {
func TestDisk_io_counters(t *testing.T) { func TestDisk_io_counters(t *testing.T) {
ret, err := IOCounters() ret, err := IOCounters()
skipIfNotImplementedErr(t, err)
if err != nil { if err != nil {
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }

Loading…
Cancel
Save