forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpowerdomain_test.go
49 lines (43 loc) · 1.01 KB
/
powerdomain_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var powerDomainBody = `{
"@odata.type": "#PowerDomain.v1_2_1.PowerDomain",
"Id": "Row1",
"Name": "Row #1 Domain",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"Links": {
"ManagedBy": [
{
"@odata.id": "/redfish/v1/Managers/BMC"
}
],
"RackPDUs": [
{
"@odata.id": "/redfish/v1/PowerEquipment/RackPDUs/1"
}
]
},
"@odata.id": "/redfish/v1/Facilities/Room237/PowerDomains/Row1"
}`
// TestPowerDomain tests the parsing of PowerDomain objects.
func TestPowerDomain(t *testing.T) {
var result PowerDomain
err := json.NewDecoder(strings.NewReader(powerDomainBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "Row1", result.ID)
assertEquals(t, "Row #1 Domain", result.Name)
assertEquals(t, "/redfish/v1/Managers/BMC", result.managedBy[0])
assertEquals(t, "/redfish/v1/PowerEquipment/RackPDUs/1", result.rackPDUs[0])
}