add additional wrappers test

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2022-03-10 12:19:51 +03:00
parent 30d7528ee7
commit aae1f2bbe6
3 changed files with 35 additions and 16 deletions

View File

@ -19,6 +19,7 @@ import (
"go.unistack.org/micro/v3/codec" "go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/register" "go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/router" "go.unistack.org/micro/v3/router"
"google.golang.org/protobuf/types/known/wrapperspb"
) )
var defaultHTTPCodecs = map[string]codec.Codec{ 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")) 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) 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 { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -11,6 +11,7 @@ import (
_ "go.unistack.org/micro-proto/v3/openapiv3" _ "go.unistack.org/micro-proto/v3/openapiv3"
protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl" protoimpl "google.golang.org/protobuf/runtime/protoimpl"
wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
reflect "reflect" reflect "reflect"
sync "sync" sync "sync"
) )
@ -27,7 +28,8 @@ type LookupUserReq struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields 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() { func (x *LookupUserReq) Reset() {
@ -69,6 +71,13 @@ func (x *LookupUserReq) GetUsername() string {
return "" return ""
} }
func (x *LookupUserReq) GetStr() *wrapperspb.StringValue {
if x != nil {
return x.Str
}
return nil
}
type LookupUserRsp struct { type LookupUserRsp struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache 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, 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, 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, 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, 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, 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, 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, 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, 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_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_github_proto_goTypes = []interface{}{ var file_github_proto_goTypes = []interface{}{
(*LookupUserReq)(nil), // 0: github.LookupUserReq (*LookupUserReq)(nil), // 0: github.LookupUserReq
(*LookupUserRsp)(nil), // 1: github.LookupUserRsp (*LookupUserRsp)(nil), // 1: github.LookupUserRsp
(*Error)(nil), // 2: github.Error (*Error)(nil), // 2: github.Error
(*wrapperspb.StringValue)(nil), // 3: google.protobuf.StringValue
} }
var file_github_proto_depIdxs = []int32{ var file_github_proto_depIdxs = []int32{
0, // 0: github.Github.LookupUser:input_type -> github.LookupUserReq 3, // 0: github.LookupUserReq.str:type_name -> google.protobuf.StringValue
0, // 1: github.Github.LookupUserWithoutPath:input_type -> github.LookupUserReq 0, // 1: github.Github.LookupUser:input_type -> github.LookupUserReq
1, // 2: github.Github.LookupUser:output_type -> github.LookupUserRsp 0, // 2: github.Github.LookupUserWithoutPath:input_type -> github.LookupUserReq
1, // 3: github.Github.LookupUserWithoutPath:output_type -> github.LookupUserRsp 1, // 3: github.Github.LookupUser:output_type -> github.LookupUserRsp
2, // [2:4] is the sub-list for method output_type 1, // 4: github.Github.LookupUserWithoutPath:output_type -> github.LookupUserRsp
0, // [0:2] is the sub-list for method input_type 3, // [3:5] is the sub-list for method output_type
0, // [0:0] is the sub-list for extension type_name 1, // [1:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension extendee 1, // [1:1] is the sub-list for extension type_name
0, // [0:0] is the sub-list for field 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() } func init() { file_github_proto_init() }

View File

@ -5,6 +5,7 @@ option go_package = "github.com//unistack-org/micro-tests/client/http/proto;pb";
import "api/annotations.proto"; import "api/annotations.proto";
import "openapiv3/annotations.proto"; import "openapiv3/annotations.proto";
import "google/protobuf/wrappers.proto";
service Github { service Github {
rpc LookupUser(LookupUserReq) returns (LookupUserRsp) { rpc LookupUser(LookupUserReq) returns (LookupUserRsp) {
@ -38,6 +39,7 @@ service Github {
message LookupUserReq { message LookupUserReq {
string username = 1; string username = 1;
google.protobuf.StringValue str = 2;
}; };
message LookupUserRsp { message LookupUserRsp {