Skip to content

Commit 52409d0

Browse files
Fixed tests
1 parent ebe4714 commit 52409d0

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

sensor/cpu_test.go

+25-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestCPUUsage(t *testing.T) {
3838
require.EqualValues(t, output, res)
3939
}
4040

41-
func TestCPUTemp(t *testing.T) {
41+
func TestCPUTemp_Intel(t *testing.T) {
4242
input := `
4343
coretemp-isa-0000
4444
Adapter: ISA adapter
@@ -57,10 +57,6 @@ func TestCPUTemp(t *testing.T) {
5757
pch_cannonlake-virtual-0
5858
Adapter: Virtual device
5959
temp1: +37.0°C
60-
61-
k10temp-pci-00c3
62-
Adapter: PCI adapter
63-
Tctl: +39.6°C
6460
`
6561
output := &entity.Payload{
6662
State: "99.0",
@@ -72,7 +68,30 @@ func TestCPUTemp(t *testing.T) {
7268
"core_4": "38.0",
7369
"core_5": "39.0",
7470
"temp_1": "37.0",
75-
"Tctl": "39.6",
71+
},
72+
}
73+
74+
c := NewCPUTemp(entity.Meta{"celsius": true})
75+
76+
res, err := c.process(input)
77+
require.NoError(t, err)
78+
require.EqualValues(t, output, res)
79+
}
80+
81+
func TestCPUTemp_AMD(t *testing.T) {
82+
input := `
83+
k10temp-pci-00c3
84+
Adapter: PCI adapter
85+
Tctl: +39.6°C
86+
87+
acpitz-acpi-0
88+
Adapter: ACPI interface
89+
temp1: +27.8°C (crit = +119.0°C)
90+
`
91+
output := &entity.Payload{
92+
State: "39.6",
93+
Attributes: map[string]interface{}{
94+
"temp_1": "27.8",
7695
},
7796
}
7897

0 commit comments

Comments
 (0)