mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
32 lines
795 B
Go
32 lines
795 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 TestCollectHostCPU_Collect(t *testing.T) {
|
|
c := &CollectHostCPU{
|
|
hostCollector: &troubleshootv1beta2.CPU{},
|
|
BundlePath: "",
|
|
}
|
|
got, err := c.Collect(nil)
|
|
require.NoError(t, err)
|
|
|
|
require.Contains(t, got, "host-collectors/system/cpu.json")
|
|
values := got["host-collectors/system/cpu.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, 2, len(m))
|
|
assert.Contains(t, m, "logicalCount")
|
|
assert.Contains(t, m, "physicalCount")
|
|
}
|