forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter_test.go
55 lines (47 loc) · 1.16 KB
/
filter_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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var filterBody = `{
"@odata.type": "#Filter.v1_0_1.Filter",
"Id": "1",
"Name": "Cooling Loop Filter",
"ServicedDate": "2020-12-24T08:00:00Z",
"ServiceHours": 5791,
"RatedServiceHours": 10000,
"Manufacturer": "Contoso",
"Model": "MyCoffee",
"PartNumber": "Cone4",
"Status": {
"State": "Enabled",
"Health": "OK"
},
"Location": {
"Placement": {
"Row": "North 1"
}
},
"@odata.id": "/redfish/v1/ThermalEquipment/CDUs/1/Filters/1"
}`
// TestFilter tests the parsing of Filter objects.
func TestFilter(t *testing.T) {
var result Filter
err := json.NewDecoder(strings.NewReader(filterBody)).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
assertEquals(t, "1", result.ID)
assertEquals(t, "Cooling Loop Filter", result.Name)
assertEquals(t, "North 1", result.Location.Placement.Row)
if result.RatedServiceHours != 10000 {
t.Errorf("Expected rated service hours: %.2f", result.RatedServiceHours)
}
if result.ServiceHours != 5791 {
t.Errorf("Expected rated service hours: %.2f", result.ServiceHours)
}
}