forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreservoir_test.go
65 lines (56 loc) · 1.47 KB
/
reservoir_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var reservoirBody = `{
"@odata.type": "#Reservoir.v1_0_1.Reservoir",
"Id": "1",
"ReservoirType": "Reserve",
"Name": "Cooling Loop Reservoir",
"Manufacturer": "Contoso",
"Model": "Tarantino",
"CapacityLiters": 10,
"PartNumber": "Pink",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"Location": {
"Placement": {
"Row": "North 1"
}
},
"FluidLevelPercent": {
"Reading": 64.8
},
"InternalPressurekPa": {
"Reading": 138.7
},
"@odata.id": "/redfish/v1/ThermalEquipment/CDUs/1/Reservoirs/1"
}`
// TestReservoir tests the parsing of Reservoir objects.
func TestReservoir(t *testing.T) {
var result Reservoir
err := json.NewDecoder(strings.NewReader(reservoirBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "1", result.ID)
assertEquals(t, "Cooling Loop Reservoir", result.Name)
assertEquals(t, "Reserve", string(result.ReservoirType))
assertEquals(t, "North 1", result.Location.Placement.Row)
if result.CapacityLiters != 10 {
t.Errorf("Unexpected CapacityLiters: %.2f", result.CapacityLiters)
}
if result.FluidLevelPercent.Reading != 64.8 {
t.Errorf("Unexpected FluidLevelPercent.Reading: %.2f", result.FluidLevelPercent.Reading)
}
if result.InternalPressurekPa.Reading != 138.7 {
t.Errorf("Unexpected InternalPressurekPa.Reading: %.2f", result.InternalPressurekPa.Reading)
}
}