@@ -2,12 +2,21 @@ package utils
22
33import (
44 "testing"
5+ "time"
56
67 opentracinglog "github.com/opentracing/opentracing-go/log"
78 "go.uber.org/zap"
89 "go.uber.org/zap/zapcore"
910)
1011
12+ type stringer struct {
13+ string
14+ }
15+
16+ func (s stringer ) String () string {
17+ return s .string
18+ }
19+
1120func TestFieldsConversion (t * testing.T ) {
1221
1322 TestData := []struct {
@@ -26,6 +35,14 @@ func TestFieldsConversion(t *testing.T) {
2635 zap .String ("" , "123" ),
2736 opentracinglog .String ("" , "123" ),
2837 },
38+ {
39+ zap .Stringer ("namespace" , stringer {"" }),
40+ opentracinglog .String ("namespace" , "" ),
41+ },
42+ {
43+ zap .Stringer ("" , stringer {"123" }),
44+ opentracinglog .String ("" , "123" ),
45+ },
2946 {
3047 zap .Int ("namespace" , 1 ),
3148 opentracinglog .Int64 ("namespace" , 1 ),
@@ -46,6 +63,10 @@ func TestFieldsConversion(t *testing.T) {
4663 zap .Uint64 ("namespace" , 1 ),
4764 opentracinglog .Uint64 ("namespace" , 1 ),
4865 },
66+ {
67+ zap .Duration ("namespace" , time .Second ),
68+ opentracinglog .String ("namespace" , "1s" ),
69+ },
4970 {
5071 zap .Float32 ("namespace" , 1 ),
5172 opentracinglog .Float32 ("namespace" , 1 ),
0 commit comments