diff --git a/Makefile b/Makefile index 89117093..1bf7a10f 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ run-image: docker run ghcr.io/linuxsuren/api-testing:dev copy: build sudo cp bin/atest /usr/local/bin/ -copy-restart: +copy-restart: build atest service stop make copy atest service restart diff --git a/pkg/server/fake_server.go b/pkg/server/fake_server.go index ca01e7d1..eb07fc53 100644 --- a/pkg/server/fake_server.go +++ b/pkg/server/fake_server.go @@ -39,6 +39,15 @@ func (s *fakeServer) GetVersion(ctx context.Context, in *Empty) (reply *HelloRep return } +// Sample returns a sample of the test task +func (s *fakeServer) Sample(ctx context.Context, in *Empty) (reply *HelloReply, err error) { + reply = &HelloReply{ + Message: "", + } + err = s.err + return +} + // NewFakeClient creates a fake client func NewFakeClient(ctx context.Context, version string, err error) (RunnerClient, func()) { buffer := 101024 * 1024 diff --git a/pkg/server/remote_server.go b/pkg/server/remote_server.go index 46ea79e3..dc52b4a6 100644 --- a/pkg/server/remote_server.go +++ b/pkg/server/remote_server.go @@ -13,6 +13,7 @@ import ( "github.com/linuxsuren/api-testing/pkg/runner" "github.com/linuxsuren/api-testing/pkg/testing" "github.com/linuxsuren/api-testing/pkg/version" + "github.com/linuxsuren/api-testing/sample" ) type server struct { @@ -140,6 +141,12 @@ func (s *server) GetVersion(ctx context.Context, in *Empty) (reply *HelloReply, return } +// Sample returns a sample of the test task +func (s *server) Sample(ctx context.Context, in *Empty) (reply *HelloReply, err error) { + reply = &HelloReply{Message: sample.TestSuiteGitLab} + return +} + func findParentTestCases(testcase *testing.TestCase, suite *testing.TestSuite) (testcases []testing.TestCase) { reg, matchErr := regexp.Compile(`(.*?\{\{.*\.\w*.*?\}\})`) targetReg, targetErr := regexp.Compile(`\.\w*`) diff --git a/pkg/server/remote_server_test.go b/pkg/server/remote_server_test.go index e562878f..ab8dc3c3 100644 --- a/pkg/server/remote_server_test.go +++ b/pkg/server/remote_server_test.go @@ -9,6 +9,7 @@ import ( "github.com/h2non/gock" atesting "github.com/linuxsuren/api-testing/pkg/testing" + "github.com/linuxsuren/api-testing/sample" "github.com/stretchr/testify/assert" ) @@ -61,6 +62,10 @@ func TestRemoteServer(t *testing.T) { ver, err = server.GetVersion(context.TODO(), &Empty{}) assert.Empty(t, ver.Message) assert.Nil(t, err) + + ver, err = server.Sample(context.TODO(), &Empty{}) + assert.Nil(t, err) + assert.Equal(t, sample.TestSuiteGitLab, ver.Message) } func TestFindParentTestCases(t *testing.T) { diff --git a/pkg/server/server.pb.go b/pkg/server/server.pb.go index a241d6d4..38d5cefd 100644 --- a/pkg/server/server.pb.go +++ b/pkg/server/server.pb.go @@ -1,205 +1,328 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.12.4 // source: pkg/server/server.proto package server import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type TestTask struct { - Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` - CaseName string `protobuf:"bytes,3,opt,name=caseName,proto3" json:"caseName,omitempty"` - Level string `protobuf:"bytes,4,opt,name=level,proto3" json:"level,omitempty"` - Env map[string]string `protobuf:"bytes,5,rep,name=env,proto3" json:"env,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TestTask) Reset() { *m = TestTask{} } -func (m *TestTask) String() string { return proto.CompactTextString(m) } -func (*TestTask) ProtoMessage() {} -func (*TestTask) Descriptor() ([]byte, []int) { - return fileDescriptor_36fb7b77b8f76c98, []int{0} -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *TestTask) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestTask.Unmarshal(m, b) -} -func (m *TestTask) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestTask.Marshal(b, m, deterministic) + Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + Kind string `protobuf:"bytes,2,opt,name=kind,proto3" json:"kind,omitempty"` + CaseName string `protobuf:"bytes,3,opt,name=caseName,proto3" json:"caseName,omitempty"` + Level string `protobuf:"bytes,4,opt,name=level,proto3" json:"level,omitempty"` + Env map[string]string `protobuf:"bytes,5,rep,name=env,proto3" json:"env,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (m *TestTask) XXX_Merge(src proto.Message) { - xxx_messageInfo_TestTask.Merge(m, src) + +func (x *TestTask) Reset() { + *x = TestTask{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_server_server_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *TestTask) XXX_Size() int { - return xxx_messageInfo_TestTask.Size(m) + +func (x *TestTask) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *TestTask) XXX_DiscardUnknown() { - xxx_messageInfo_TestTask.DiscardUnknown(m) + +func (*TestTask) ProtoMessage() {} + +func (x *TestTask) ProtoReflect() protoreflect.Message { + mi := &file_pkg_server_server_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_TestTask proto.InternalMessageInfo +// Deprecated: Use TestTask.ProtoReflect.Descriptor instead. +func (*TestTask) Descriptor() ([]byte, []int) { + return file_pkg_server_server_proto_rawDescGZIP(), []int{0} +} -func (m *TestTask) GetData() string { - if m != nil { - return m.Data +func (x *TestTask) GetData() string { + if x != nil { + return x.Data } return "" } -func (m *TestTask) GetKind() string { - if m != nil { - return m.Kind +func (x *TestTask) GetKind() string { + if x != nil { + return x.Kind } return "" } -func (m *TestTask) GetCaseName() string { - if m != nil { - return m.CaseName +func (x *TestTask) GetCaseName() string { + if x != nil { + return x.CaseName } return "" } -func (m *TestTask) GetLevel() string { - if m != nil { - return m.Level +func (x *TestTask) GetLevel() string { + if x != nil { + return x.Level } return "" } -func (m *TestTask) GetEnv() map[string]string { - if m != nil { - return m.Env +func (x *TestTask) GetEnv() map[string]string { + if x != nil { + return x.Env } return nil } type HelloReply struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *HelloReply) Reset() { *m = HelloReply{} } -func (m *HelloReply) String() string { return proto.CompactTextString(m) } -func (*HelloReply) ProtoMessage() {} -func (*HelloReply) Descriptor() ([]byte, []int) { - return fileDescriptor_36fb7b77b8f76c98, []int{1} + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } -func (m *HelloReply) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_HelloReply.Unmarshal(m, b) -} -func (m *HelloReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_HelloReply.Marshal(b, m, deterministic) -} -func (m *HelloReply) XXX_Merge(src proto.Message) { - xxx_messageInfo_HelloReply.Merge(m, src) +func (x *HelloReply) Reset() { + *x = HelloReply{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_server_server_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *HelloReply) XXX_Size() int { - return xxx_messageInfo_HelloReply.Size(m) + +func (x *HelloReply) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *HelloReply) XXX_DiscardUnknown() { - xxx_messageInfo_HelloReply.DiscardUnknown(m) + +func (*HelloReply) ProtoMessage() {} + +func (x *HelloReply) ProtoReflect() protoreflect.Message { + mi := &file_pkg_server_server_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_HelloReply proto.InternalMessageInfo +// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. +func (*HelloReply) Descriptor() ([]byte, []int) { + return file_pkg_server_server_proto_rawDescGZIP(), []int{1} +} -func (m *HelloReply) GetMessage() string { - if m != nil { - return m.Message +func (x *HelloReply) GetMessage() string { + if x != nil { + return x.Message } return "" } -func (m *HelloReply) GetError() string { - if m != nil { - return m.Error +func (x *HelloReply) GetError() string { + if x != nil { + return x.Error } return "" } type Empty struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_36fb7b77b8f76c98, []int{2} +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_pkg_server_server_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Empty) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Empty.Unmarshal(m, b) -} -func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Empty.Marshal(b, m, deterministic) +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *Empty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Empty.Merge(m, src) + +func (*Empty) ProtoMessage() {} + +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_pkg_server_server_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func (m *Empty) XXX_Size() int { - return xxx_messageInfo_Empty.Size(m) + +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_pkg_server_server_proto_rawDescGZIP(), []int{2} } -func (m *Empty) XXX_DiscardUnknown() { - xxx_messageInfo_Empty.DiscardUnknown(m) + +var File_pkg_server_server_proto protoreflect.FileDescriptor + +var file_pkg_server_server_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x22, 0xc9, 0x01, 0x0a, 0x08, 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x12, + 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x73, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x61, 0x73, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x2b, 0x0a, 0x03, 0x65, 0x6e, 0x76, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x54, + 0x65, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x45, 0x6e, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x03, 0x65, 0x6e, 0x76, 0x1a, 0x36, 0x0a, 0x08, 0x45, 0x6e, 0x76, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3c, 0x0a, + 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x07, 0x0a, 0x05, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x32, 0x99, 0x01, 0x0a, 0x06, 0x52, 0x75, 0x6e, 0x6e, 0x65, 0x72, 0x12, + 0x2d, 0x0a, 0x03, 0x52, 0x75, 0x6e, 0x12, 0x10, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, + 0x54, 0x65, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x2d, + 0x0a, 0x06, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x0d, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x31, 0x0a, + 0x0a, 0x47, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0d, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, + 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, + 0x69, 0x6e, 0x75, 0x78, 0x73, 0x75, 0x72, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2d, 0x74, 0x65, + 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -var xxx_messageInfo_Empty proto.InternalMessageInfo +var ( + file_pkg_server_server_proto_rawDescOnce sync.Once + file_pkg_server_server_proto_rawDescData = file_pkg_server_server_proto_rawDesc +) -func init() { - proto.RegisterType((*TestTask)(nil), "server.TestTask") - proto.RegisterMapType((map[string]string)(nil), "server.TestTask.EnvEntry") - proto.RegisterType((*HelloReply)(nil), "server.HelloReply") - proto.RegisterType((*Empty)(nil), "server.Empty") +func file_pkg_server_server_proto_rawDescGZIP() []byte { + file_pkg_server_server_proto_rawDescOnce.Do(func() { + file_pkg_server_server_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_server_server_proto_rawDescData) + }) + return file_pkg_server_server_proto_rawDescData } -func init() { - proto.RegisterFile("pkg/server/server.proto", fileDescriptor_36fb7b77b8f76c98) +var file_pkg_server_server_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_pkg_server_server_proto_goTypes = []interface{}{ + (*TestTask)(nil), // 0: server.TestTask + (*HelloReply)(nil), // 1: server.HelloReply + (*Empty)(nil), // 2: server.Empty + nil, // 3: server.TestTask.EnvEntry +} +var file_pkg_server_server_proto_depIdxs = []int32{ + 3, // 0: server.TestTask.env:type_name -> server.TestTask.EnvEntry + 0, // 1: server.Runner.Run:input_type -> server.TestTask + 2, // 2: server.Runner.Sample:input_type -> server.Empty + 2, // 3: server.Runner.GetVersion:input_type -> server.Empty + 1, // 4: server.Runner.Run:output_type -> server.HelloReply + 1, // 5: server.Runner.Sample:output_type -> server.HelloReply + 1, // 6: server.Runner.GetVersion:output_type -> server.HelloReply + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] 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 } -var fileDescriptor_36fb7b77b8f76c98 = []byte{ - // 311 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4f, 0x4b, 0xf3, 0x40, - 0x10, 0xc6, 0xdf, 0x34, 0xfd, 0xf7, 0x8e, 0x08, 0x65, 0x10, 0x8c, 0x3d, 0x95, 0x9c, 0x0a, 0xda, - 0x04, 0x2b, 0x88, 0x88, 0x27, 0xa1, 0xe8, 0xc9, 0x43, 0x28, 0x1e, 0xbc, 0x6d, 0xdb, 0x21, 0xc6, - 0x6c, 0x36, 0x61, 0x77, 0x13, 0xcc, 0x47, 0xf4, 0x5b, 0xc9, 0x6e, 0xb2, 0x16, 0xc4, 0xd3, 0xce, - 0xef, 0xd9, 0x99, 0x79, 0x1e, 0x18, 0x38, 0xaf, 0xf2, 0x34, 0x56, 0x24, 0x1b, 0x92, 0xfd, 0x13, - 0x55, 0xb2, 0xd4, 0x25, 0x8e, 0x3b, 0x0a, 0xbf, 0x3c, 0x98, 0x6e, 0x49, 0xe9, 0x2d, 0x53, 0x39, - 0x22, 0x0c, 0x0f, 0x4c, 0xb3, 0xc0, 0x5b, 0x78, 0xcb, 0xff, 0x89, 0xad, 0x8d, 0x96, 0x67, 0xe2, - 0x10, 0x0c, 0x3a, 0xcd, 0xd4, 0x38, 0x87, 0xe9, 0x9e, 0x29, 0x7a, 0x61, 0x05, 0x05, 0xbe, 0xd5, - 0x7f, 0x18, 0xcf, 0x60, 0xc4, 0xa9, 0x21, 0x1e, 0x0c, 0xed, 0x47, 0x07, 0x78, 0x09, 0x3e, 0x89, - 0x26, 0x18, 0x2d, 0xfc, 0xe5, 0xc9, 0xfa, 0x22, 0xea, 0xa3, 0x38, 0xe3, 0x68, 0x23, 0x9a, 0x8d, - 0xd0, 0xb2, 0x4d, 0x4c, 0xd7, 0xfc, 0x16, 0xa6, 0x4e, 0xc0, 0x19, 0xf8, 0x39, 0xb5, 0x7d, 0x22, - 0x53, 0x1a, 0x83, 0x86, 0xf1, 0x9a, 0xfa, 0x44, 0x1d, 0xdc, 0x0f, 0xee, 0xbc, 0xf0, 0x01, 0xe0, - 0x99, 0x38, 0x2f, 0x13, 0xaa, 0x78, 0x8b, 0x01, 0x4c, 0x0a, 0x52, 0x8a, 0xa5, 0xd4, 0x4f, 0x3b, - 0x34, 0x1b, 0x48, 0xca, 0x52, 0xba, 0x0d, 0x16, 0xc2, 0x09, 0x8c, 0x36, 0x45, 0xa5, 0xdb, 0xf5, - 0x07, 0x8c, 0x93, 0x5a, 0x08, 0x92, 0xb8, 0x02, 0x3f, 0xa9, 0x05, 0xce, 0x7e, 0xe7, 0x9d, 0xa3, - 0x53, 0x8e, 0x7e, 0xe1, 0x3f, 0xbc, 0x06, 0x78, 0x22, 0xfd, 0x4a, 0x52, 0x65, 0xa5, 0xc0, 0x53, - 0xd7, 0x63, 0xb7, 0xfe, 0x3d, 0xf2, 0x18, 0xbd, 0x5d, 0xa5, 0x99, 0x7e, 0xaf, 0x77, 0xd1, 0xbe, - 0x2c, 0x62, 0x9e, 0x89, 0xfa, 0x53, 0xd5, 0x92, 0x44, 0xcc, 0xaa, 0x6c, 0xa5, 0x49, 0xe9, 0x4c, - 0xa4, 0xf1, 0xf1, 0x86, 0xbb, 0xb1, 0xbd, 0xde, 0xcd, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, - 0xde, 0x43, 0x18, 0xd8, 0x01, 0x00, 0x00, +func init() { file_pkg_server_server_proto_init() } +func file_pkg_server_server_proto_init() { + if File_pkg_server_server_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_pkg_server_server_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestTask); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_server_server_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pkg_server_server_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_pkg_server_server_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_pkg_server_server_proto_goTypes, + DependencyIndexes: file_pkg_server_server_proto_depIdxs, + MessageInfos: file_pkg_server_server_proto_msgTypes, + }.Build() + File_pkg_server_server_proto = out.File + file_pkg_server_server_proto_rawDesc = nil + file_pkg_server_server_proto_goTypes = nil + file_pkg_server_server_proto_depIdxs = nil } diff --git a/pkg/server/server.proto b/pkg/server/server.proto index 84c71944..e1fdc95b 100644 --- a/pkg/server/server.proto +++ b/pkg/server/server.proto @@ -6,6 +6,7 @@ package server; service Runner { rpc Run (TestTask) returns (HelloReply) {} + rpc Sample(Empty) returns (HelloReply) {} rpc GetVersion(Empty) returns (HelloReply) {} } diff --git a/pkg/server/server_grpc.pb.go b/pkg/server/server_grpc.pb.go index 9989fbb9..fb04d6e9 100644 --- a/pkg/server/server_grpc.pb.go +++ b/pkg/server/server_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v4.22.2 +// - protoc v3.12.4 // source: pkg/server/server.proto package server @@ -23,6 +23,7 @@ const _ = grpc.SupportPackageIsVersion7 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type RunnerClient interface { Run(ctx context.Context, in *TestTask, opts ...grpc.CallOption) (*HelloReply, error) + Sample(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*HelloReply, error) GetVersion(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*HelloReply, error) } @@ -43,6 +44,15 @@ func (c *runnerClient) Run(ctx context.Context, in *TestTask, opts ...grpc.CallO return out, nil } +func (c *runnerClient) Sample(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*HelloReply, error) { + out := new(HelloReply) + err := c.cc.Invoke(ctx, "/server.Runner/Sample", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *runnerClient) GetVersion(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*HelloReply, error) { out := new(HelloReply) err := c.cc.Invoke(ctx, "/server.Runner/GetVersion", in, out, opts...) @@ -57,6 +67,7 @@ func (c *runnerClient) GetVersion(ctx context.Context, in *Empty, opts ...grpc.C // for forward compatibility type RunnerServer interface { Run(context.Context, *TestTask) (*HelloReply, error) + Sample(context.Context, *Empty) (*HelloReply, error) GetVersion(context.Context, *Empty) (*HelloReply, error) mustEmbedUnimplementedRunnerServer() } @@ -68,6 +79,9 @@ type UnimplementedRunnerServer struct { func (UnimplementedRunnerServer) Run(context.Context, *TestTask) (*HelloReply, error) { return nil, status.Errorf(codes.Unimplemented, "method Run not implemented") } +func (UnimplementedRunnerServer) Sample(context.Context, *Empty) (*HelloReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Sample not implemented") +} func (UnimplementedRunnerServer) GetVersion(context.Context, *Empty) (*HelloReply, error) { return nil, status.Errorf(codes.Unimplemented, "method GetVersion not implemented") } @@ -102,6 +116,24 @@ func _Runner_Run_Handler(srv interface{}, ctx context.Context, dec func(interfac return interceptor(ctx, in, info, handler) } +func _Runner_Sample_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RunnerServer).Sample(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/server.Runner/Sample", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RunnerServer).Sample(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + func _Runner_GetVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Empty) if err := dec(in); err != nil { @@ -131,6 +163,10 @@ var Runner_ServiceDesc = grpc.ServiceDesc{ MethodName: "Run", Handler: _Runner_Run_Handler, }, + { + MethodName: "Sample", + Handler: _Runner_Sample_Handler, + }, { MethodName: "GetVersion", Handler: _Runner_GetVersion_Handler, diff --git a/pkg/server/server_grpc_test.go b/pkg/server/server_grpc_test.go index eeb2ad1c..8292f9cf 100644 --- a/pkg/server/server_grpc_test.go +++ b/pkg/server/server_grpc_test.go @@ -55,6 +55,10 @@ func TestServer(t *testing.T) { assert.NotNil(t, reply) assert.Nil(t, err) + reply, err = client.Sample(context.Background(), &server.Empty{}) + assert.Nil(t, err) + assert.Empty(t, reply.GetMessage()) + clientWithErr, _ := server.NewFakeClient(context.Background(), "version", errors.New("fake")) reply, err = clientWithErr.GetVersion(context.Background(), &server.Empty{}) assert.NotNil(t, err)