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

pull/928/head
Lomanic 5 years ago
parent 78a65a67a9
commit ea86cbc3ff

@ -5,15 +5,23 @@ import (
"runtime"
"testing"
"github.com/shirou/gopsutil/internal/common"
"github.com/stretchr/testify/assert"
)
func skipIfNotImplementedErr(t *testing.T, err error) {
if err == common.ErrNotImplementedError {
t.Skip("not implemented")
}
}
func TestVirtual_memory(t *testing.T) {
if runtime.GOOS == "solaris" {
t.Skip("Only .Total is supported on Solaris")
}
v, err := VirtualMemory()
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}
@ -44,7 +52,7 @@ func TestVirtual_memory(t *testing.T) {
"Total should be computable (%v): %v", totalStr, v)
assert.True(t, runtime.GOOS == "windows" || v.Free > 0)
assert.True(t, v.Available > v.Free,
assert.True(t, runtime.GOOS == "windows" || v.Available > v.Free,
"Free should be a subset of Available: %v", v)
inDelta := assert.InDelta
@ -58,6 +66,7 @@ func TestVirtual_memory(t *testing.T) {
func TestSwap_memory(t *testing.T) {
v, err := SwapMemory()
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}

Loading…
Cancel
Save