forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoolingloop_test.go
66 lines (59 loc) · 1.71 KB
/
coolingloop_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var coolingLoopBody = `{
"@odata.type": "#CoolingLoop.v1_0_2.CoolingLoop",
"Id": "BuildingChiller",
"Name": "Feed from building chiller",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"UserLabel": "Building Chiller",
"Coolant": {
"CoolantType": "Water",
"AdditiveName": "Generic cooling water biocide",
"AdditivePercent": 0
},
"CoolantLevelStatus": "OK",
"CoolantQuality": "OK",
"CoolantLevelPercent": {
"Reading": 95
},
"SupplyEquipmentNames": [
"Chiller"
],
"ConsumingEquipmentNames": [
"Rack #1 CDU",
"Rack #2 CDU",
"Rack #3 CDU",
"Rack #4 CDU"
],
"@odata.id": "/redfish/v1/ThermalEquipment/CoolingLoops/BuildingChiller"
}`
// TestCoolingLoop tests the parsing of CoolingLoop objects.
func TestCoolingLoop(t *testing.T) {
var result CoolingLoop
err := json.NewDecoder(strings.NewReader(coolingLoopBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "BuildingChiller", result.ID)
assertEquals(t, "Feed from building chiller", result.Name)
assertEquals(t, "Building Chiller", result.UserLabel)
assertEquals(t, "Water", string(result.Coolant.CoolantType))
assertEquals(t, "Generic cooling water biocide", result.Coolant.AdditiveName)
assertEquals(t, "OK", string(result.CoolantLevelStatus))
assertEquals(t, "OK", string(result.CoolantQuality))
assertEquals(t, "Chiller", result.SupplyEquipmentNames[0])
assertEquals(t, "Rack #3 CDU", result.ConsumingEquipmentNames[2])
if result.CoolantLevelPercent.Reading != 95 {
t.Errorf("Unexpected CoolantLevelPercent, got %.2f", result.CoolantLevelPercent.Reading)
}
}