forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpcieslots_test.go
67 lines (61 loc) · 1.47 KB
/
pcieslots_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
66
67
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"fmt"
"strings"
"testing"
)
var pcieSlotsBody = strings.NewReader(
`{
"@odata.context": "/redfish/v1/$metadata#PCIeSlots.PCIeSlots",
"@odata.etag": "\"1683342314\"",
"@odata.id": "/redfish/v1/Chassis/Self/PCIeSlots",
"@odata.type": "#PCIeSlots.v1_1_1.PCIeSlots",
"Description": "Pcie Slot #11",
"Id": "11",
"Name": "PcieSlot_11",
"Slots": [
{
"HotPluggable": true,
"Lanes": 32,
"Links": {
"PCIeDevice": [
{
"@odata.id": "/redfish/v1/Chassis/Self/PCIeDevices/00_00_01"
}
],
"[email protected]": 1
},
"Location": {
"PartLocation": {
"LocationOrdinalValue": 11,
"LocationType": "Slot",
"ServiceLabel": "Slot F"
}
},
"PCIeType": "Gen3",
"SlotType": "FullLength",
"Status": {
"Health": "OK",
"State": "Enabled"
}
}
]
}`)
// TestPCIeSlots tests the parsing of PCIeSlots objects.
func TestPCIeSlots(t *testing.T) {
var result PCIeSlots
err := json.NewDecoder(pcieSlotsBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "11", result.ID)
assertEquals(t, "PcieSlot_11", result.Name)
assertEquals(t, "true", fmt.Sprint(result.Slots[0].HotPluggable))
assertEquals(t, "32", fmt.Sprint(result.Slots[0].Lanes))
assertEquals(t, "Gen3", fmt.Sprint(result.Slots[0].PCIeType))
assertEquals(t, "FullLength", fmt.Sprint(result.Slots[0].SlotType))
}