Added timestamp, hostname, and rawlog to list of reserved fields

This commit is contained in:
Xavi Ramirez 2018-05-10 23:56:32 +00:00
parent 74634a6bf0
commit 8f2ad09efa
2 changed files with 16 additions and 0 deletions

View file

@ -15,6 +15,9 @@ var reservedFields = []string{
"prefix",
"postfix",
"decoder_msg_type",
"timestamp",
"hostname",
"rawlog",
}
func stringInSlice(s string, slice []string) bool {

View file

@ -65,6 +65,19 @@ func TestKayveeDecoding(t *testing.T) {
},
ExpectedError: nil,
},
Spec{
Title: "Reserved fields are respected",
Input: `prefix {"a":"b","prefix":"no-override","postfix":"no-override",` +
`"decoder_msg_type":"no-override","timestamp":"no-override",` +
`"hostname":"no-override","rawlog":"no-override"} postfix`,
ExpectedOutput: map[string]interface{}{
"prefix": "prefix ",
"postfix": " postfix",
"a": "b",
"decoder_msg_type": "Kayvee",
},
ExpectedError: nil,
},
Spec{
Title: "Returns NonKayveeError if not JSON in body",
Input: `prefix { postfix`,