Files
troubleshoot/pkg/collect/host_memory_test.go
Evans Mungai ebeed77287 chore: Upgrade gopsutil to v3 (#927)
* Add host collector tests related to gopsutil upgrade

* Upgrade gopsutil to v3
2022-12-24 13:42:13 +13:00

31 lines
763 B
Go

package collect
import (
"encoding/json"
"testing"
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestCollectHostMemory_Collect(t *testing.T) {
c := &CollectHostMemory{
hostCollector: &troubleshootv1beta2.Memory{},
BundlePath: "",
}
got, err := c.Collect(nil)
require.NoError(t, err)
require.Contains(t, got, "host-collectors/system/memory.json")
values := got["host-collectors/system/memory.json"]
var m map[string]int
err = json.Unmarshal(values, &m)
require.NoError(t, err)
// Check if values exist. They will be different on different machines.
assert.Equal(t, 1, len(m))
assert.Contains(t, m, "total")
}