forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddresspool_test.go
73 lines (62 loc) · 1.52 KB
/
addresspool_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var addressPoolBody = strings.NewReader(
`{
"@odata.type": "#AddressPool.v1_2_4.AddressPool",
"Id": "AP1",
"Name": "Address Pool 1",
"Description": "Address Pool 1",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"GenZ": {
"MinCID": 1,
"MaxCID": 4096,
"MinSID": 100,
"MaxSID": 8192,
"AccessKey": "0x1A"
},
"Links": {
"Endpoints": [
{
"@odata.id": "/redfish/v1/Fabrics/GenZ/Endpoints/1"
}
]
},
"@odata.id": "/redfish/v1/Fabrics/GenZ/AddressPools/AP1"
}
}`)
// TestAddressPool tests the parsing of AddressPool objects.
func TestAddressPool(t *testing.T) {
var result AddressPool
err := json.NewDecoder(addressPoolBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "AP1", result.ID)
assertEquals(t, "Address Pool 1", result.Name)
assertEquals(t, "0x1A", result.GenZ.AccessKey)
if result.GenZ.MinCID != 1 {
t.Errorf("Expected Genz.MinCID to be 1, got %d", result.GenZ.MinCID)
}
if result.GenZ.MinSID != 100 {
t.Errorf("Expected Genz.MinSID to be 100, got %d", result.GenZ.MinSID)
}
if result.GenZ.MaxCID != 4096 {
t.Errorf("Expected Genz.MaxCID to be 4096, got %d", result.GenZ.MaxCID)
}
if result.GenZ.MaxSID != 8192 {
t.Errorf("Expected Genz.MinSID to be 8192, got %d", result.GenZ.MaxSID)
}
if len(result.endpoints) != 1 {
t.Errorf("Expected 1 endpoint, got %#v", result.endpoints)
}
}