forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemorychunks_test.go
84 lines (75 loc) · 1.81 KB
/
memorychunks_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
75
76
77
78
79
80
81
82
83
84
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var memoryChunksBody = `{
"@odata.type": "#MemoryChunks.v1_6_1.MemoryChunks",
"Name": "Memory Chunk - Whole System",
"Id": "1",
"MemoryChunkSizeMiB": 32768,
"AddressRangeType": "Volatile",
"IsMirrorEnabled": false,
"IsSpare": false,
"InterleaveSets": [
{
"Memory": {
"@odata.id": "/redfish/v1/Systems/2/Memory/1"
}
},
{
"Memory": {
"@odata.id": "/redfish/v1/Systems/2/Memory/2"
}
},
{
"Memory": {
"@odata.id": "/redfish/v1/Systems/2/Memory/3"
}
},
{
"Memory": {
"@odata.id": "/redfish/v1/Systems/2/Memory/4"
}
}
],
"@Redfish.Settings": {
"@odata.type": "#Settings.v1_3_5.Settings",
"SettingsObject": {
"@odata.id": "/redfish/v1/Systems/2/MemoryDomains/1/MemoryChunks/1/SD"
},
"Time": "2012-03-07T14:44.30-05:00",
"ETag": "someetag",
"Messages": [
{
"MessageId": "Base.1.0.Success"
}
]
},
"@odata.id": "/redfish/v1/Systems/2/MemoryDomains/1/MemoryChunks/1"
}`
// TestMemoryChunks tests the parsing of MemoryChunks objects.
func TestMemoryChunks(t *testing.T) {
var result MemoryChunks
err := json.NewDecoder(strings.NewReader(memoryChunksBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "1", result.ID)
assertEquals(t, "Memory Chunk - Whole System", result.Name)
assertEquals(t, "Volatile", string(result.AddressRangeType))
assertEquals(t, "/redfish/v1/Systems/2/Memory/4", result.InterleaveSets[3].memory)
if result.IsSpare {
t.Error("Expected not to be a spare")
}
if result.IsMirrorEnabled {
t.Error("Expected mirror not to be enabled")
}
if result.MemoryChunkSizeMiB != 32768 {
t.Errorf("Unexpected memory chunk size: %d", result.MemoryChunkSizeMiB)
}
}