forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogentry_test.go
70 lines (58 loc) · 1.62 KB
/
logentry_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
69
70
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"strings"
"testing"
)
var logEntryBody = strings.NewReader(
`{
"@odata.context": "/redfish/v1/$metadata#LogEntry.LogEntry",
"@odata.type": "#LogEntry.v1_0_0.LogEntry",
"@odata.id": "/redfish/v1/LogEntry",
"Id": "LogEntry-1",
"Name": "LogEntryOne",
"Description": "LogEntry One",
"Created": "2012-03-07T14:44+06:00",
"EntryCode": "Informational",
"EntryType": "Event",
"EventGroupId": 21,
"EventId": "event_entry_1",
"EventTimestamp": "2012-03-07T14:44+06:00",
"Message": "Sorry folks, the parks closed.",
"MessageArgs": [],
"SensorNumber": 1,
"SensorType": "Processor",
"Severity": "Warning"
}`)
// TestLogEntry tests the parsing of LogEntry objects.
func TestLogEntry(t *testing.T) {
var result LogEntry
err := json.NewDecoder(logEntryBody).Decode(&result)
if err != nil {
t.Errorf("Error decoding JSON: %s", err)
}
if result.ID != "LogEntry-1" {
t.Errorf("Received invalid ID: %s", result.ID)
}
if result.Name != "LogEntryOne" {
t.Errorf("Received invalid name: %s", result.Name)
}
if result.EntryCode != InformationalLogEntryCode {
t.Errorf("Received entry code: %s", result.EntryCode)
}
if result.EventGroupID != 21 {
t.Errorf("Expected group ID 21, got %d", result.EventGroupID)
}
if result.SensorNumber != 1 {
t.Errorf("Received sensor number %d", result.SensorNumber)
}
if result.SensorType != ProcessorSensorType {
t.Errorf("Received sensor type %s", result.SensorType)
}
if result.Severity != WarningEventSeverity {
t.Errorf("Received log severity %s", result.Severity)
}
}