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

This commit is contained in:
Lomanic 2020-08-29 18:29:36 +02:00
parent 38f6ed0e0c
commit b7781f5858
1 changed files with 11 additions and 0 deletions

View File

@ -5,14 +5,23 @@ import (
"runtime"
"sync"
"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) {
path := "/"
if runtime.GOOS == "windows" {
path = "C:"
}
v, err := Usage(path)
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}
@ -23,6 +32,7 @@ func TestDisk_usage(t *testing.T) {
func TestDisk_partitions(t *testing.T) {
ret, err := Partitions(false)
skipIfNotImplementedErr(t, err)
if err != nil || len(ret) == 0 {
t.Errorf("error %v", err)
}
@ -41,6 +51,7 @@ func TestDisk_partitions(t *testing.T) {
func TestDisk_io_counters(t *testing.T) {
ret, err := IOCounters()
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}