Added ReplyError as nil in the response of the StringQuery if missing

This commit is contained in:
Trial97
2020-11-17 10:14:43 +02:00
committed by Dan Christian Bogos
parent 53e68bd2cf
commit 326c86f583
3 changed files with 5 additions and 0 deletions

View File

@@ -162,6 +162,9 @@ func (aS *AnalyzerService) V1StringQuery(args *QueryArgs, reply *[]map[string]in
if dur, err := utils.IfaceAsDuration(obj.Fields[utils.RequestDuration]); err == nil {
obj.Fields[utils.RequestDuration] = dur.String()
}
if val, has := obj.Fields[utils.ReplyError]; !has || len(utils.IfaceAsString(val)) == 0 {
obj.Fields[utils.ReplyError] = nil
}
if lCntFltrs != 0 {
repDP, err := unmarshalJSON(rep)
if err != nil {

View File

@@ -278,6 +278,7 @@ func TestAnalyzersV1Search(t *testing.T) {
"Reply": json.RawMessage(`"Pong"`),
"RequestSource": "127.0.0.1:5566",
"RequestStartTime": t1.Add(-24 * time.Hour).UTC().Format(time.RFC3339),
"ReplyError": nil,
}}
reply = []map[string]interface{}{}
if err = anz.V1StringQuery(&QueryArgs{HeaderFilters: utils.RequestDuration + ":>=" + strconv.FormatInt(int64(time.Hour), 10)}, &reply); err != nil {