diff --git a/logger/unwrap/unwrap_test.go b/logger/unwrap/unwrap_test.go new file mode 100644 index 0000000..2402bfd --- /dev/null +++ b/logger/unwrap/unwrap_test.go @@ -0,0 +1,27 @@ +package unwrap_test + +import ( + "database/sql" + "fmt" + "strings" + "testing" + + "github.com/golang/protobuf/ptypes/wrappers" + "go.unistack.org/micro/v3/logger/unwrap" +) + +func TestWrappers(t *testing.T) { + type CustomerInfo struct { + MainPhone *wrappers.StringValue `logger:"take"` + BankClientId string `logger:"take"` + NullString sql.NullString `logger:"take"` + } + + c := &CustomerInfo{MainPhone: &wrappers.StringValue{Value: "+712334"}, BankClientId: "12345", NullString: sql.NullString{String: "test"}} + + buf := fmt.Sprintf("%#v", unwrap.Unwrap(c, unwrap.Tagged(true))) + cmp := `&unwrap_test.CustomerInfo{MainPhone:(*wrapperspb.StringValue){Value:"+712334"}, BankClientId:"12345", NullString:(sql.NullString){String:"test"}}` + if strings.Compare(buf, cmp) != 0 { + t.Fatalf("not proper written \n%s\n%s", cmp, buf) + } +}