forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzone_test.go
74 lines (67 loc) · 1.63 KB
/
zone_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var zoneBody = `{
"@Redfish.CollectionCapabilities": {
"@odata.type": "#CollectionCapabilities.v1_2_0.CollectionCapabilities",
"Capabilities": [
{
"CapabilitiesObject": {
"@odata.id": "/redfish/v1/Systems/Capabilities"
},
"Links": {
"TargetCollection": {
"@odata.id": "/redfish/v1/Systems"
}
},
"UseCase": "ComputerSystemComposition"
}
],
"MaxMembers": 1
},
"@odata.context": "/redfish/v1/$metadata#Zone.Zone",
"@odata.etag": "\"1712866586\"",
"@odata.id": "/redfish/v1/CompositionService/ResourceZones/1",
"@odata.type": "#Zone.v1_3_1.Zone",
"Description": "Resource Zone 1",
"Id": "1",
"Links": {
"ResourceBlocks": [
{
"@odata.id": "/redfish/v1/CompositionService/ResourceBlocks/ComputeBlock"
},
{
"@odata.id": "/redfish/v1/CompositionService/ResourceBlocks/DrivesBlock"
},
{
"@odata.id": "/redfish/v1/CompositionService/ResourceBlocks/NetworkBlock"
}
]
},
"Name": "Resource Zone 1",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
}
}`
// TestZone tests the parsing of Zone objects.
func TestZone(t *testing.T) {
var result Zone
err := json.NewDecoder(strings.NewReader(zoneBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "1", result.ID)
assertEquals(t, "Resource Zone 1", result.Name)
assertEquals(t, "Resource Zone 1", result.Description)
if len(result.resourceBlocks) != 3 {
t.Errorf("Expected 3 resource blocks, got %#v", result.resourceBlocks)
}
}