forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheater_test.go
65 lines (57 loc) · 1.56 KB
/
heater_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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var heaterBody = `{
"@odata.type": "#Heater.v1_0_1.Heater",
"Id": "CPU1Heater",
"Description": "Heater for CPU1",
"Name": "Heater 1",
"PhysicalContext": "CPU",
"Manufacturer": "Contoso Heaters",
"Model": "CPUHeater",
"SerialNumber": "SNDHM0123456789",
"PartNumber": "12345-123",
"SparePartNumber": "54321-321",
"LocationIndicatorActive": false,
"HotPluggable": true,
"Status": {
"Health": "OK",
"State": "Enabled"
},
"Links": {
"Processors": [
{
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Processors/CPU1"
}
]
},
"Metrics": {
"@odata.id": "/redfish/v1/Chassis/1U/ThermalSubsystem/Heaters/CPU1Heater/Metrics"
},
"@odata.id": "/redfish/v1/Chassis/1U/ThermalSubsystem/Heaters/CPU1Heater"
}`
// TestHeater tests the parsing of Heater objects.
func TestHeater(t *testing.T) {
var result Heater
err := json.NewDecoder(strings.NewReader(heaterBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "CPU1Heater", result.ID)
assertEquals(t, "Heater 1", result.Name)
assertEquals(t, "CPU", string(result.PhysicalContext))
assertEquals(t, "/redfish/v1/Systems/437XR1138R2/Processors/CPU1", result.processors[0])
assertEquals(t, "/redfish/v1/Chassis/1U/ThermalSubsystem/Heaters/CPU1Heater/Metrics", result.metrics)
if result.LocationIndicatorActive {
t.Error("Expected location indicator not to be active")
}
if !result.HotPluggable {
t.Error("Expected to be hot pluggable")
}
}