forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetricreport_test.go
58 lines (52 loc) · 1.83 KB
/
metricreport_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var metricReportBody = `{
"@odata.type": "#MetricReport.v1_5_0.MetricReport",
"Id": "AvgPlatformPowerUsage",
"Name": "Average Platform Power Usage metric report",
"MetricReportDefinition": {
"@odata.id": "/redfish/v1/TelemetryService/MetricReportDefinitions/AvgPlatformPowerUsage"
},
"MetricValues": [
{
"MetricId": "AverageConsumedWatts",
"MetricValue": "100",
"Timestamp": "2016-11-08T12:25:00-05:00",
"MetricProperty": "/redfish/v1/Chassis/Tray_1/Power#/0/PowerConsumedWatts"
},
{
"MetricId": "AverageConsumedWatts",
"MetricValue": "94",
"Timestamp": "2016-11-08T13:25:00-05:00",
"MetricProperty": "/redfish/v1/Chassis/Tray_1/Power#/0/PowerConsumedWatts"
},
{
"MetricId": "AverageConsumedWatts",
"MetricValue": "100",
"Timestamp": "2016-11-08T14:25:00-05:00",
"MetricProperty": "/redfish/v1/Chassis/Tray_1/Power#/0/PowerConsumedWatts"
}
],
"@odata.id": "/redfish/v1/TelemetryService/MetricReports/AvgPlatformPowerUsage"
}`
// TestMetricReport tests the parsing of MetricReport objects.
func TestMetricReport(t *testing.T) {
var result MetricReport
err := json.NewDecoder(strings.NewReader(metricReportBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "AvgPlatformPowerUsage", result.ID)
assertEquals(t, "Average Platform Power Usage metric report", result.Name)
assertEquals(t, "/redfish/v1/TelemetryService/MetricReportDefinitions/AvgPlatformPowerUsage", result.metricReportDefinition)
assertEquals(t, "AverageConsumedWatts", result.MetricValues[0].MetricID)
assertEquals(t, "94", result.MetricValues[1].MetricValue)
assertEquals(t, "/redfish/v1/Chassis/Tray_1/Power#/0/PowerConsumedWatts", result.MetricValues[2].MetricProperty)
}