forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpciefunction_test.go
85 lines (75 loc) · 2 KB
/
pciefunction_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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var pcieFunctionBody = strings.NewReader(
`{
"@odata.context": "/redfish/v1/$metadata#PCIeFunction.PCIeFunction",
"@odata.type": "#PCIeFunction.v1_0_0.PCIeFunction",
"@odata.id": "/redfish/v1/PCIeFunction",
"Id": "PCIeFunction-1",
"Name": "PCIeFunctionOne",
"Description": "PCIeFunction One",
"ClassCode": "01",
"DeviceClass": "MassStorageController",
"DeviceId": "01",
"FunctionId": 10,
"FunctionType": "Virtual",
"Links": {
"Drives": [{
"@odata.id": "/redfish/v1/Drives/1"
}],
"[email protected]": 1,
"EthernetInterfaces": [{
"@odata.id": "/redfish/v1/EthernetInterfaces/1"
}],
"[email protected]": 1,
"NetworkDeviceFunctions": [{
"@odata.id": "/redfish/v1/NetworkDeviceFunction/1"
}],
"[email protected]": 1,
"PCIeDevice": {
"@odata.id": "/redfish/v1/PCIeDevices/1"
},
"StorageControllers": [{
"@odata.id": "/redfish/v1/StorageControllers/1"
}],
"[email protected]": 1
},
"RevisionId": "1.0",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"SubsystemId": "1F",
"SubsystemVendorId": "0a",
"VendorId": "4f"
}`)
// TestPCIeFunction tests the parsing of PCIeFunction objects.
func TestPCIeFunction(t *testing.T) {
var result PCIeFunction
err := json.NewDecoder(pcieFunctionBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
if result.ID != "PCIeFunction-1" {
t.Errorf("Received invalid ID: %s", result.ID)
}
if result.Name != "PCIeFunctionOne" {
t.Errorf("Received invalid name: %s", result.Name)
}
if result.DeviceClass != MassStorageControllerDeviceClass {
t.Errorf("Invalid device class: %s", result.DeviceClass)
}
if result.FunctionID != 10 {
t.Errorf("Invalid function ID: %d", result.FunctionID)
}
if result.FunctionType != VirtualFunctionType {
t.Errorf("Invalid function type: %s", result.FunctionType)
}
}