forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleakdetection_test.go
68 lines (62 loc) · 1.9 KB
/
leakdetection_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"fmt"
"strings"
"testing"
)
var leakDetectionBody = `{
"@odata.type": "#LeakDetection.v1_0_0.LeakDetection",
"Id": "LeakDetection",
"Name": "Leak Detection Systems",
"Status": {
"State": "Enabled",
"Health": "OK",
"Conditions": []
},
"LeakDetectorGroups": [
{
"GroupName": "Detectors under and around the CDU",
"HumidityPercent": {
"Reading": 45
},
"Detectors": [
{
"DataSourceUri": "/redfish/v1/ThermalEquipment/CDUs/1/LeakDetection/LeakDetectors/Moisture",
"DeviceName": "Moisture-type Leak Detector",
"DetectorState": "OK"
},
{
"DeviceName": "Leak Detection Rope 1",
"DetectorState": "OK"
},
{
"DataSourceUri": "/redfish/v1/ThermalEquipment/CDUs/1/LeakDetection/LeakDetectors/Overflow",
"DeviceName": "Overflow Float Switch",
"DetectorState": "OK"
}
]
}
],
"LeakDetectors": {
"@odata.id": "/redfish/v1/ThermalEquipment/CDUs/1/LeakDetection/LeakDetectors"
},
"@odata.id": "/redfish/v1/ThermalEquipment/CDUs/1/LeakDetection"
}`
// TestLeakDetection tests the parsing of LeakDetection objects.
func TestLeakDetection(t *testing.T) {
var result LeakDetection
err := json.NewDecoder(strings.NewReader(leakDetectionBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "LeakDetection", result.ID)
assertEquals(t, "Leak Detection Systems", result.Name)
assertEquals(t, "Detectors under and around the CDU", result.LeakDetectorGroups[0].GroupName)
assertEquals(t, "45", fmt.Sprintf("%.0f", result.LeakDetectorGroups[0].HumidityPercent.Reading))
assertEquals(t, "/redfish/v1/ThermalEquipment/CDUs/1/LeakDetection/LeakDetectors/Overflow", result.LeakDetectorGroups[0].Detectors[2].DataSourceURI)
assertEquals(t, "/redfish/v1/ThermalEquipment/CDUs/1/LeakDetection/LeakDetectors", result.leakDetectors)
}