From aae1f2bbe68b3bfc093e3f239b72692d6745691b Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 10 Mar 2022 12:19:51 +0300 Subject: [PATCH] add additional wrappers test Signed-off-by: Vasiliy Tolstov --- client/http/http_test.go | 3 ++- client/http/proto/github.pb.go | 46 +++++++++++++++++++++++----------- client/http/proto/github.proto | 2 ++ 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/client/http/http_test.go b/client/http/http_test.go index df133d0..9e1a220 100644 --- a/client/http/http_test.go +++ b/client/http/http_test.go @@ -19,6 +19,7 @@ import ( "go.unistack.org/micro/v3/codec" "go.unistack.org/micro/v3/register" "go.unistack.org/micro/v3/router" + "google.golang.org/protobuf/types/known/wrapperspb" ) var defaultHTTPCodecs = map[string]codec.Codec{ @@ -63,7 +64,7 @@ func TestNative(t *testing.T) { c := client.NewClientCallOptions(mhttp.NewClient(client.ContentType("application/json"), client.Codec("application/json", jsoncodec.NewCodec())), client.WithAddress("https://api.github.com")) gh := pb.NewGithubClient("github", c) - rsp, err := gh.LookupUser(context.TODO(), &pb.LookupUserReq{Username: "vtolstov"}) + rsp, err := gh.LookupUser(context.TODO(), &pb.LookupUserReq{Username: "vtolstov", Str: wrapperspb.String("test")}) if err != nil { t.Fatal(err) } diff --git a/client/http/proto/github.pb.go b/client/http/proto/github.pb.go index 586991a..42e08c4 100644 --- a/client/http/proto/github.pb.go +++ b/client/http/proto/github.pb.go @@ -11,6 +11,7 @@ import ( _ "go.unistack.org/micro-proto/v3/openapiv3" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" reflect "reflect" sync "sync" ) @@ -27,7 +28,8 @@ type LookupUserReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Str *wrapperspb.StringValue `protobuf:"bytes,2,opt,name=str,proto3" json:"str,omitempty"` } func (x *LookupUserReq) Reset() { @@ -69,6 +71,13 @@ func (x *LookupUserReq) GetUsername() string { return "" } +func (x *LookupUserReq) GetStr() *wrapperspb.StringValue { + if x != nil { + return x.Str + } + return nil +} + type LookupUserRsp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -178,10 +187,15 @@ var file_github_proto_rawDesc = []byte{ 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x1a, 0x15, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2b, 0x0a, 0x0d, 0x4c, 0x6f, + 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, + 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, 0x0d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, - 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a, 0x0d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, + 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2e, 0x0a, 0x03, 0x73, 0x74, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x52, 0x03, 0x73, 0x74, 0x72, 0x22, 0x23, 0x0a, 0x0d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x55, 0x73, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x4e, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, @@ -227,20 +241,22 @@ func file_github_proto_rawDescGZIP() []byte { var file_github_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_github_proto_goTypes = []interface{}{ - (*LookupUserReq)(nil), // 0: github.LookupUserReq - (*LookupUserRsp)(nil), // 1: github.LookupUserRsp - (*Error)(nil), // 2: github.Error + (*LookupUserReq)(nil), // 0: github.LookupUserReq + (*LookupUserRsp)(nil), // 1: github.LookupUserRsp + (*Error)(nil), // 2: github.Error + (*wrapperspb.StringValue)(nil), // 3: google.protobuf.StringValue } var file_github_proto_depIdxs = []int32{ - 0, // 0: github.Github.LookupUser:input_type -> github.LookupUserReq - 0, // 1: github.Github.LookupUserWithoutPath:input_type -> github.LookupUserReq - 1, // 2: github.Github.LookupUser:output_type -> github.LookupUserRsp - 1, // 3: github.Github.LookupUserWithoutPath:output_type -> github.LookupUserRsp - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 3, // 0: github.LookupUserReq.str:type_name -> google.protobuf.StringValue + 0, // 1: github.Github.LookupUser:input_type -> github.LookupUserReq + 0, // 2: github.Github.LookupUserWithoutPath:input_type -> github.LookupUserReq + 1, // 3: github.Github.LookupUser:output_type -> github.LookupUserRsp + 1, // 4: github.Github.LookupUserWithoutPath:output_type -> github.LookupUserRsp + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_github_proto_init() } diff --git a/client/http/proto/github.proto b/client/http/proto/github.proto index ae3a642..7499822 100644 --- a/client/http/proto/github.proto +++ b/client/http/proto/github.proto @@ -5,6 +5,7 @@ option go_package = "github.com//unistack-org/micro-tests/client/http/proto;pb"; import "api/annotations.proto"; import "openapiv3/annotations.proto"; +import "google/protobuf/wrappers.proto"; service Github { rpc LookupUser(LookupUserReq) returns (LookupUserRsp) { @@ -38,6 +39,7 @@ service Github { message LookupUserReq { string username = 1; + google.protobuf.StringValue str = 2; }; message LookupUserRsp {