File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
libbeat/processors/actions Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -491,6 +491,27 @@ func TestOverwriteMetadata(t *testing.T) {
491491 assert .Equal (t , expected , actual )
492492}
493493
494+ func TestAddErrorToEventOnUnmarshalError (t * testing.T ) {
495+ testConfig := common .MustNewConfigFrom (map [string ]interface {}{
496+ "fields" : "message" ,
497+ "add_error_key" : true ,
498+ })
499+
500+ input := common.MapStr {
501+ "message" : "Broken JSON [[" ,
502+ }
503+
504+ actual := getActualValue (t , testConfig , input )
505+
506+ errObj , ok := actual ["error" ].(common.MapStr )
507+ require .True (t , ok , "'error' field not present or of invalid type" )
508+ require .NotNil (t , actual ["error" ])
509+
510+ assert .Equal (t , "message" , errObj ["field" ])
511+ assert .NotNil (t , errObj ["data" ])
512+ assert .NotNil (t , errObj ["message" ])
513+ }
514+
494515func getActualValue (t * testing.T , config * common.Config , input common.MapStr ) common.MapStr {
495516 log := logp .NewLogger ("decode_json_fields_test" )
496517
You can’t perform that action at this time.
0 commit comments