forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfabric_test.go
52 lines (44 loc) · 1.07 KB
/
fabric_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var fabricBody = strings.NewReader(
`{
"@odata.context": "/redfish/v1/$metadata#Fabric.Fabric",
"@odata.id": "/redfish/v1/Fabrics/PCIe",
"@odata.type": "#Fabric.v1_3_0.Fabric",
"Description": "PCIe Fabric",
"FabricType": "PCIe",
"Id": "PCIe",
"Links": {},
"Name": "PCIe Fabric",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Switches": {
"@odata.id": "/redfish/v1/Fabrics/PCIe/Switches"
}
}`)
// TestFabric tests the parsing of Fabric objects.
func TestFabric(t *testing.T) {
var result Fabric
err := json.NewDecoder(fabricBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
if result.ID != "PCIe" {
t.Errorf("Received invalid ID: %s", result.ID)
}
if result.Name != "PCIe Fabric" {
t.Errorf("Received invalid name: %s", result.Name)
}
assertEquals(t, "OK", string(result.Status.Health))
assertEquals(t, "/redfish/v1/Fabrics/PCIe/Switches", result.switches)
}