From c44edd7cac0b007c1643fcfd4691643269fe2fbe Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sun, 5 Jun 2022 11:51:21 +0800 Subject: [PATCH] test: fix fails (#1970) --- core/logx/tracelogger_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/logx/tracelogger_test.go b/core/logx/tracelogger_test.go index 0866b663..7dac6d01 100644 --- a/core/logx/tracelogger_test.go +++ b/core/logx/tracelogger_test.go @@ -3,6 +3,7 @@ package logx import ( "context" "encoding/json" + "io" "strings" "sync/atomic" "testing" @@ -193,6 +194,22 @@ func TestTraceWithoutContext(t *testing.T) { func validate(t *testing.T, body string, expectedTrace, expectedSpan bool) { var val mockValue + dec := json.NewDecoder(strings.NewReader(body)) + + for { + var doc mockValue + err := dec.Decode(&doc) + if err == io.EOF { + // all done + break + } + if err != nil { + continue + } + + val = doc + } + assert.Nil(t, json.Unmarshal([]byte(body), &val), body) assert.Equal(t, expectedTrace, len(val.Trace) > 0, body) assert.Equal(t, expectedSpan, len(val.Span) > 0, body)