forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraphicscontroller_test.go
68 lines (62 loc) · 1.79 KB
/
graphicscontroller_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var graphicsControllerBody = `{
"@odata.type": "#GraphicsController.v1_0_1.GraphicsController",
"Id": "GPU1",
"Name": "Contoso Graphics Controller 1",
"AssetTag": "",
"Manufacturer": "Contoso",
"Model": "GPU1",
"SKU": "80937",
"SerialNumber": "2M220100SL",
"PartNumber": "G37891",
"SparePartNumber": "G37890",
"BiosVersion": "90.02.17.00.7D",
"DriverVersion": "27.21.14.6079 (Contoso 460.79) DCH / Win 10 64",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"Location": {
"PartLocation": {
"ServiceLabel": "Slot 1",
"LocationOrdinalValue": 1,
"LocationType": "Slot",
"Orientation": "LeftToRight",
"Reference": "Rear"
}
},
"Ports": {
"@odata.id": "/redfish/v1/Systems/1/GraphicsControllers/GPU1/Ports"
},
"Links": {
"Processors": [
{
"@odata.id": "/redfish/v1/Systems/1/Processors/GPU"
}
]
},
"@odata.id": "/redfish/v1/Systems/1/GraphicsControllers/GPU1"
}`
// TestGraphicsController tests the parsing of GraphicsController objects.
func TestGraphicsController(t *testing.T) {
var result GraphicsController
err := json.NewDecoder(strings.NewReader(graphicsControllerBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "GPU1", result.ID)
assertEquals(t, "Contoso Graphics Controller 1", result.Name)
assertEquals(t, "90.02.17.00.7D", result.BiosVersion)
assertEquals(t, "27.21.14.6079 (Contoso 460.79) DCH / Win 10 64", result.DriverVersion)
assertEquals(t, "LeftToRight", string(result.Location.PartLocation.Orientation))
assertEquals(t, "/redfish/v1/Systems/1/GraphicsControllers/GPU1/Ports", result.ports)
assertEquals(t, "/redfish/v1/Systems/1/Processors/GPU", result.processors[0])
}