forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp_test.go
37 lines (28 loc) · 803 Bytes
/
temp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package temp
import (
"testing"
"github.com/shirou/gopsutil/host"
"github.com/stretchr/testify/require"
"github.com/influxdata/telegraf/plugins/inputs/system"
"github.com/influxdata/telegraf/testutil"
)
func TestTemperature(t *testing.T) {
var mps system.MockPS
var err error
defer mps.AssertExpectations(t)
var acc testutil.Accumulator
ts := host.TemperatureStat{
SensorKey: "coretemp_sensor1_crit",
Temperature: 60.5,
}
mps.On("Temperature").Return([]host.TemperatureStat{ts}, nil)
err = (&Temperature{ps: &mps}).Gather(&acc)
require.NoError(t, err)
expectedFields := map[string]interface{}{
"temp": float64(60.5),
}
expectedTags := map[string]string{
"sensor": "coretemp_sensor1_crit",
}
acc.AssertContainsTaggedFields(t, "temp", expectedFields, expectedTags)
}