forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcable_test.go
72 lines (65 loc) · 1.76 KB
/
cable_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var cableBody = `{
"@odata.type": "#Cable.v1_2_2.Cable",
"Id": "hdmi_dp",
"Name": "HDMI to DP Cable",
"UserDescription": "HDMI to DisplayPort Cable",
"UpstreamName": "HDMI0",
"DownstreamName": "Video Out",
"CableType": "HDMI",
"LengthMeters": 0.1,
"CableClass": "Video",
"UpstreamConnectorTypes": [
"HDMI"
],
"DownstreamConnectorTypes": [
"DisplayPort"
],
"Links": {
"UpstreamChassis": [
{
"@odata.id": "/redfish/v1/Chassis/bmc"
}
]
},
"PartNumber": "934AMS02X",
"Manufacturer": "Cable Co.",
"SerialNumber": "2345791",
"Vendor": "Cablestore",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"CableStatus": "Normal",
"@odata.id": "/redfish/v1/Cables/hdmi_dp"
}`
// TestCable tests the parsing of Cable objects.
func TestCable(t *testing.T) {
var result Cable
err := json.NewDecoder(strings.NewReader(cableBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "hdmi_dp", result.ID)
assertEquals(t, "HDMI to DP Cable", result.Name)
assertEquals(t, "HDMI to DisplayPort Cable", result.UserDescription)
assertEquals(t, "HDMI0", result.UpstreamName)
assertEquals(t, "Video Out", result.DownstreamName)
assertEquals(t, "HDMI", result.CableType)
assertEquals(t, "Normal", string(result.CableStatus))
assertEquals(t, "Video", string(result.CableClass))
assertEquals(t, "/redfish/v1/Chassis/bmc", result.upstreamChassis[0])
assertEquals(t, "HDMI", string(result.UpstreamConnectorTypes[0]))
assertEquals(t, "DisplayPort", string(result.DownstreamConnectorTypes[0]))
if result.LengthMeters != 0.1 {
t.Errorf("Unexpected cable meter length: %.2f", result.LengthMeters)
}
}