forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitchmetrics_test.go
63 lines (54 loc) · 1.74 KB
/
switchmetrics_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var switchMetricsBody = `{
"@odata.type": "#SwitchMetrics.v1_0_1.SwitchMetrics",
"Id": "SwitchMetrics",
"Name": "PCIe Switch Metrics",
"PCIeErrors": {
"CorrectableErrorCount": 1,
"NonFatalErrorCount": 0,
"FatalErrorCount": 0,
"L0ToRecoveryCount": 0,
"ReplayCount": 0,
"ReplayRolloverCount": 0,
"NAKSentCount": 0,
"NAKReceivedCount": 0
},
"InternalMemoryMetrics": {
"CurrentPeriod": {
"CorrectableECCErrorCount": 1,
"UncorrectableECCErrorCount": 0
},
"LifeTime": {
"CorrectableECCErrorCount": 0,
"UncorrectableECCErrorCount": 1
}
},
"@odata.id": "/redfish/v1/Fabrics/PCIe/Switches/1/SwitchMetrics"
}`
// TestSwitchMetrics tests the parsing of SwitchMetrics objects.
func TestSwitchMetrics(t *testing.T) {
var result SwitchMetrics
err := json.NewDecoder(strings.NewReader(switchMetricsBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "SwitchMetrics", result.ID)
assertEquals(t, "PCIe Switch Metrics", result.Name)
if result.PCIeErrors.CorrectableErrorCount != 1 {
t.Errorf("Unexpected PCIeErrors.CorrectableErrorCount: %d", result.PCIeErrors.CorrectableErrorCount)
}
if result.InternalMemoryMetrics.CurrentPeriod.CorrectableECCErrorCount != 1 {
t.Errorf("Unexpected InternalMemoryMetrics.CurrentPeriod.CorrectableECCErrorCount: %d", result.InternalMemoryMetrics.CurrentPeriod.CorrectableECCErrorCount)
}
if result.InternalMemoryMetrics.LifeTime.UncorrectableECCErrorCount != 1 {
t.Errorf("Unexpected InternalMemoryMetrics.LifeTime.UncorrectableECCErrorCount: %d", result.InternalMemoryMetrics.LifeTime.UncorrectableECCErrorCount)
}
}