From 81423e1cf2dd972ea8b8c924a5e986a6baf7a8b1 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 6 Feb 2023 23:03:53 +0300 Subject: [PATCH] additional logger/unwrap tests Signed-off-by: Vasiliy Tolstov --- logger/unwrap/unwrap_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 logger/unwrap/unwrap_test.go 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) + } +}