Example #1
0
func TestBuildCPUMultipleStat_OK(t *testing.T) {

	float64Array := []float64{11.904762, 27.5, 5, 2.5, 7.692308, 31.707317, 2.4390242, 7.317073}
	cpu := stats.BuildCPUMultipleStat(float64Array)

	assert := assert.New(t)
	assert.NotNil(cpu)
	assert.Equal(len(float64Array), cpu.NumberOfCores)
	assert.Equal(stats.GetAverage(float64Array), cpu.AverageUsagePercentage)
	assert.Equal(len(float64Array), len(cpu.UsagePercentagePerCore))
}
Example #2
0
func TestBuildCPUMultipleStat_NOK_emptyArray(t *testing.T) {

	float64Array := []float64{}
	cpu := stats.BuildCPUMultipleStat(float64Array)

	assert := assert.New(t)
	assert.NotNil(cpu)
	assert.Equal(len(float64Array), cpu.NumberOfCores)
	assert.Equal(stats.GetAverage(float64Array), cpu.AverageUsagePercentage)
	assert.Equal(float64(0), cpu.AverageUsagePercentage)
	assert.Equal(len(float64Array), len(cpu.UsagePercentagePerCore))
	assert.Equal(0, len(cpu.UsagePercentagePerCore))
}