forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstoragecontroller_test.go
90 lines (83 loc) · 2.38 KB
/
storagecontroller_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
86
87
88
89
90
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var storageControllerBody = `{
"@odata.type": "#StorageController.v1_7_2.StorageController",
"Id": "1",
"Name": "NVMe IO Controller",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"SupportedControllerProtocols": [
"NVMeOverFabrics"
],
"NVMeControllerProperties": {
"NVMeVersion": "1.4",
"ControllerType": "IO",
"NVMeControllerAttributes": {
"ReportsUUIDList": false,
"SupportsSQAssociations": false,
"ReportsNamespaceGranularity": false,
"SupportsTrafficBasedKeepAlive": false,
"SupportsPredictableLatencyMode": false,
"SupportsEnduranceGroups": false,
"SupportsReadRecoveryLevels": false,
"SupportsNVMSets": true,
"SupportsExceedingPowerOfNonOperationalState": false,
"Supports128BitHostId": false
},
"NVMeSMARTCriticalWarnings": {
"PMRUnreliable": false,
"PowerBackupFailed": false,
"MediaInReadOnly": false,
"OverallSubsystemDegraded": false,
"SpareCapacityWornOut": false
}
},
"Links": {
"Endpoints": [
{
"@odata.id": "/redfish/v1/Fabrics/NVMeoF/Endpoints/Initiator1"
},
{
"@odata.id": "/redfish/v1/Fabrics/NVMeoF/Endpoints/Target1"
}
],
"AttachedVolumes": [
{
"@odata.id": "/redfish/v1/Storage/NVMeoF/Volumes/1"
},
{
"@odata.id": "/redfish/v1/Storage/NVMeoF/Volumes/3"
},
{
"@odata.id": "/redfish/v1/Storage/NVMeoF/Volumes/4"
}
]
},
"@odata.id": "/redfish/v1/Storage/NVMeoF/Controllers/1"
}`
// TestStorageController tests the parsing of StorageController objects.
func TestStorageController(t *testing.T) {
var result StorageController
err := json.NewDecoder(strings.NewReader(storageControllerBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "1", result.ID)
assertEquals(t, "NVMe IO Controller", result.Name)
assertEquals(t, "NVMeOverFabrics", string(result.SupportedControllerProtocols[0]))
assertEquals(t, "IO", string(result.NVMeControllerProperties.ControllerType))
assertEquals(t, "/redfish/v1/Fabrics/NVMeoF/Endpoints/Target1", result.endpoints[1])
assertEquals(t, "/redfish/v1/Storage/NVMeoF/Volumes/1", result.attachedVolumes[0])
if !result.NVMeControllerProperties.NVMeControllerAttributes.SupportsNVMSets {
t.Error("Expected NVMeControllerProperties.NVMeControllerAttributes.SupportsNVMSets to be true")
}
}