forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemorydomain_test.go
77 lines (65 loc) · 1.85 KB
/
memorydomain_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var memoryDomainBody = strings.NewReader(
`{
"@odata.context": "/redfish/v1/$metadata#MemoryDomain.MemoryDomain",
"@odata.type": "#MemoryDomain.v1_0_0.MemoryDomain",
"@odata.id": "/redfish/v1/MemoryDomain",
"Id": "MemoryDomain-1",
"Name": "MemoryDomainOne",
"Description": "MemoryDomain One",
"AllowBlockProvisioning": false,
"AllowsMemoryChunkCreation": false,
"AllowsMirroring": true,
"AllowsSparing": true,
"InterleavableMemorySets": [{
"MemorySet": [{
"@odata.id": "/redfish/v1/System/System-1/Memory/NVRAM1"
},
{
"@odata.id": "/redfish/v1/System/System-1/Memory/NVRAM2"
}
],
"[email protected]": 2
}],
"MemoryChunks": {
"@odata.id": "/redfish/v1/System/System-1/Memory/NVRAM1/Chunks"
}
}`)
// TestMemoryDomain tests the parsing of MemoryDomain objects.
func TestMemoryDomain(t *testing.T) {
var result MemoryDomain
err := json.NewDecoder(memoryDomainBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
if result.ID != "MemoryDomain-1" {
t.Errorf("Received invalid ID: %s", result.ID)
}
if result.Name != "MemoryDomainOne" {
t.Errorf("Received invalid name: %s", result.Name)
}
if result.AllowsBlockProvisioning {
t.Error("Allow block provisioning should be false")
}
if result.AllowsMemoryChunkCreation {
t.Error("Allow memory chunk creation should be false")
}
if !result.AllowsMirroring {
t.Error("Allow mirroring should be true")
}
if len(result.InterleavableMemorySets) != 1 {
t.Errorf("Should have one interleavable memory set, got: %d",
len(result.InterleavableMemorySets))
}
if result.memoryChunks != "/redfish/v1/System/System-1/Memory/NVRAM1/Chunks" {
t.Errorf("Invalid memory chunk link: %s", result.memoryChunks)
}
}