Compare commits
No commits in common. "2e1ab137ea53cab901d65622a4be8fc2ba9f2fb4" and "c5eee0ea22eea34be9b30385a3adfbdc6d4a0cdd" have entirely different histories.
2e1ab137ea
...
c5eee0ea22
1 changed files with 0 additions and 58 deletions
|
@ -1,58 +0,0 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gopkg.in/mcuadros/go-syslog.v2/format"
|
||||
)
|
||||
|
||||
var timeNow = time.Now()
|
||||
|
||||
var returnValues = map[string]interface{}{
|
||||
"prog": "test_app",
|
||||
"client": "test_client",
|
||||
"host": "my_machine",
|
||||
"msg": "test message",
|
||||
"sev": 3,
|
||||
"time": timeNow,
|
||||
}
|
||||
|
||||
var msgRFC5424 = format.LogParts{
|
||||
"version": 1,
|
||||
"app_name": returnValues["prog"],
|
||||
"client": returnValues["client"],
|
||||
"hostname": returnValues["host"],
|
||||
"proc_id": "spam_process",
|
||||
"message": returnValues["msg"],
|
||||
"facility": "hell",
|
||||
"timestamp": returnValues["time"],
|
||||
"severity": returnValues["sev"],
|
||||
}
|
||||
|
||||
var msgRFC3164 = format.LogParts{
|
||||
"tag": returnValues["prog"],
|
||||
"client": returnValues["client"],
|
||||
"hostname": returnValues["host"],
|
||||
"content": returnValues["msg"],
|
||||
"severity": returnValues["sev"],
|
||||
"timestamp": returnValues["time"],
|
||||
"proc_id": "spam_process",
|
||||
}
|
||||
|
||||
var testMessages = []format.LogParts{
|
||||
msgRFC5424,
|
||||
msgRFC3164,
|
||||
}
|
||||
|
||||
func TestLogEntryToMessage(t *testing.T) {
|
||||
for _, msg := range testMessages {
|
||||
parsedMsg := LogEntryToMessage(msg)
|
||||
|
||||
for key, value := range returnValues {
|
||||
if data, ok := parsedMsg[key]; !ok || data != value {
|
||||
t.Errorf("Missing/wrong key: %s\nmsg: %s\nparsed msg: %s\n", key, value, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue