pkg/sysinfo: remove github.com/docker/go-units dependency

It was only used in a test, and only for a single const; define
it locally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-12-16 15:12:03 +01:00
parent 6a516acb2e
commit 09ea6744fe
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -6,8 +6,6 @@ package sysinfo
import (
"strings"
"testing"
units "github.com/docker/go-units"
)
// TestMemInfo tests parseMemInfo with a static meminfo string
@ -23,20 +21,23 @@ func TestMemInfo(t *testing.T) {
Malformed3: 2 MB
Malformed4: X kB
`
const KiB = 1024
meminfo, err := parseMemInfo(strings.NewReader(input))
if err != nil {
t.Fatal(err)
}
if meminfo.MemTotal != 1*units.KiB {
if meminfo.MemTotal != 1*KiB {
t.Fatalf("Unexpected MemTotal: %d", meminfo.MemTotal)
}
if meminfo.MemFree != 3*units.KiB {
if meminfo.MemFree != 3*KiB {
t.Fatalf("Unexpected MemFree: %d", meminfo.MemFree)
}
if meminfo.SwapTotal != 4*units.KiB {
if meminfo.SwapTotal != 4*KiB {
t.Fatalf("Unexpected SwapTotal: %d", meminfo.SwapTotal)
}
if meminfo.SwapFree != 5*units.KiB {
if meminfo.SwapFree != 5*KiB {
t.Fatalf("Unexpected SwapFree: %d", meminfo.SwapFree)
}
}