additional logger/unwrap tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
acd9eab7e9
commit
81423e1cf2
27
logger/unwrap/unwrap_test.go
Normal file
27
logger/unwrap/unwrap_test.go
Normal file
@ -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)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user