diff --git a/template/mock/mock.go b/template/mock/mock.go index 6f80886..3984b4a 100644 --- a/template/mock/mock.go +++ b/template/mock/mock.go @@ -1,47 +1,73 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: api.go +// Code generated by moq; DO NOT EDIT. +// github.com/matryer/moq -// Package mock is a generated GoMock package. package mock import ( - gomock "github.com/golang/mock/gomock" - . "github.com/theplant/plantpkg/template" - reflect "reflect" + "github.com/theplant/plantpkg/template" + "sync" ) -// MockTemplateService is a mock of TemplateService interface -type MockTemplateService struct { - ctrl *gomock.Controller - recorder *MockTemplateServiceMockRecorder -} - -// MockTemplateServiceMockRecorder is the mock recorder for MockTemplateService -type MockTemplateServiceMockRecorder struct { - mock *MockTemplateService -} +var ( + lockTemplateServiceMockSayHello sync.RWMutex +) -// NewMockTemplateService creates a new mock instance -func NewMockTemplateService(ctrl *gomock.Controller) *MockTemplateService { - mock := &MockTemplateService{ctrl: ctrl} - mock.recorder = &MockTemplateServiceMockRecorder{mock} - return mock -} +// TemplateServiceMock is a mock implementation of TemplateService. +// +// func TestSomethingThatUsesTemplateService(t *testing.T) { +// +// // make and configure a mocked TemplateService +// mockedTemplateService := &TemplateServiceMock{ +// SayHelloFunc: func(input *template.SayHelloInput) (*template.SayHelloResult, error) { +// panic("TODO: mock out the SayHello method") +// }, +// } +// +// // TODO: use mockedTemplateService in code that requires TemplateService +// // and then make assertions. +// +// } +type TemplateServiceMock struct { + // SayHelloFunc mocks the SayHello method. + SayHelloFunc func(input *template.SayHelloInput) (*template.SayHelloResult, error) -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockTemplateService) EXPECT() *MockTemplateServiceMockRecorder { - return m.recorder + // calls tracks calls to the methods. + calls struct { + // SayHello holds details about calls to the SayHello method. + SayHello []struct { + // Input is the input argument value. + Input *template.SayHelloInput + } + } } -// SayHello mocks base method -func (m *MockTemplateService) SayHello(input *SayHelloInput) (*SayHelloResult, error) { - ret := m.ctrl.Call(m, "SayHello", input) - ret0, _ := ret[0].(*SayHelloResult) - ret1, _ := ret[1].(error) - return ret0, ret1 +// SayHello calls SayHelloFunc. +func (mock *TemplateServiceMock) SayHello(input *template.SayHelloInput) (*template.SayHelloResult, error) { + if mock.SayHelloFunc == nil { + panic("TemplateServiceMock.SayHelloFunc: method is nil but TemplateService.SayHello was just called") + } + callInfo := struct { + Input *template.SayHelloInput + }{ + Input: input, + } + lockTemplateServiceMockSayHello.Lock() + mock.calls.SayHello = append(mock.calls.SayHello, callInfo) + lockTemplateServiceMockSayHello.Unlock() + return mock.SayHelloFunc(input) } -// SayHello indicates an expected call of SayHello -func (mr *MockTemplateServiceMockRecorder) SayHello(input interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SayHello", reflect.TypeOf((*MockTemplateService)(nil).SayHello), input) +// SayHelloCalls gets all the calls that were made to SayHello. +// Check the length with: +// len(mockedTemplateService.SayHelloCalls()) +func (mock *TemplateServiceMock) SayHelloCalls() []struct { + Input *template.SayHelloInput +} { + var calls []struct { + Input *template.SayHelloInput + } + lockTemplateServiceMockSayHello.RLock() + calls = mock.calls.SayHello + lockTemplateServiceMockSayHello.RUnlock() + return calls } diff --git a/template/modd.conf b/template/modd.conf index 748b920..7c89a5b 100644 --- a/template/modd.conf +++ b/template/modd.conf @@ -11,5 +11,5 @@ } api.go { - prep: mockgen -source=api.go -destination=mock/mock.go -package=mock + prep: moq -out=mock/mock.go -pkg=mock . TemplateService } diff --git a/template/spec.pb.go b/template/spec.pb.go index ffd31f2..d37a435 100644 --- a/template/spec.pb.go +++ b/template/spec.pb.go @@ -1,17 +1,6 @@ -// Code generated by protoc-gen-go. +// Code generated by protoc-gen-go. DO NOT EDIT. // source: spec.proto -// DO NOT EDIT! -/* -Package template is a generated protocol buffer package. - -It is generated from these files: - spec.proto - -It has these top-level messages: - SayHelloInput - SayHelloResult -*/ package template import proto "github.com/golang/protobuf/proto" @@ -30,13 +19,35 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package type SayHelloInput struct { - Hello string `protobuf:"bytes,1,opt,name=hello" json:"hello,omitempty"` + Hello string `protobuf:"bytes,1,opt,name=hello,proto3" json:"hello,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SayHelloInput) Reset() { *m = SayHelloInput{} } +func (m *SayHelloInput) String() string { return proto.CompactTextString(m) } +func (*SayHelloInput) ProtoMessage() {} +func (*SayHelloInput) Descriptor() ([]byte, []int) { + return fileDescriptor_spec_d8f3c8df0d901829, []int{0} +} +func (m *SayHelloInput) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SayHelloInput.Unmarshal(m, b) +} +func (m *SayHelloInput) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SayHelloInput.Marshal(b, m, deterministic) +} +func (dst *SayHelloInput) XXX_Merge(src proto.Message) { + xxx_messageInfo_SayHelloInput.Merge(dst, src) +} +func (m *SayHelloInput) XXX_Size() int { + return xxx_messageInfo_SayHelloInput.Size(m) +} +func (m *SayHelloInput) XXX_DiscardUnknown() { + xxx_messageInfo_SayHelloInput.DiscardUnknown(m) } -func (m *SayHelloInput) Reset() { *m = SayHelloInput{} } -func (m *SayHelloInput) String() string { return proto.CompactTextString(m) } -func (*SayHelloInput) ProtoMessage() {} -func (*SayHelloInput) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +var xxx_messageInfo_SayHelloInput proto.InternalMessageInfo func (m *SayHelloInput) GetHello() string { if m != nil { @@ -46,13 +57,35 @@ func (m *SayHelloInput) GetHello() string { } type SayHelloResult struct { - Result string `protobuf:"bytes,1,opt,name=result" json:"result,omitempty"` + Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SayHelloResult) Reset() { *m = SayHelloResult{} } +func (m *SayHelloResult) String() string { return proto.CompactTextString(m) } +func (*SayHelloResult) ProtoMessage() {} +func (*SayHelloResult) Descriptor() ([]byte, []int) { + return fileDescriptor_spec_d8f3c8df0d901829, []int{1} +} +func (m *SayHelloResult) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SayHelloResult.Unmarshal(m, b) +} +func (m *SayHelloResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SayHelloResult.Marshal(b, m, deterministic) +} +func (dst *SayHelloResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_SayHelloResult.Merge(dst, src) +} +func (m *SayHelloResult) XXX_Size() int { + return xxx_messageInfo_SayHelloResult.Size(m) +} +func (m *SayHelloResult) XXX_DiscardUnknown() { + xxx_messageInfo_SayHelloResult.DiscardUnknown(m) } -func (m *SayHelloResult) Reset() { *m = SayHelloResult{} } -func (m *SayHelloResult) String() string { return proto.CompactTextString(m) } -func (*SayHelloResult) ProtoMessage() {} -func (*SayHelloResult) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } +var xxx_messageInfo_SayHelloResult proto.InternalMessageInfo func (m *SayHelloResult) GetResult() string { if m != nil { @@ -66,11 +99,11 @@ func init() { proto.RegisterType((*SayHelloResult)(nil), "template.SayHelloResult") } -func init() { proto.RegisterFile("spec.proto", fileDescriptor0) } +func init() { proto.RegisterFile("spec.proto", fileDescriptor_spec_d8f3c8df0d901829) } -var fileDescriptor0 = []byte{ +var fileDescriptor_spec_d8f3c8df0d901829 = []byte{ // 106 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0x2e, 0x48, 0x4d, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0x2e, 0x48, 0x4d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x28, 0x49, 0xcd, 0x2d, 0xc8, 0x49, 0x2c, 0x49, 0x55, 0x52, 0xe5, 0xe2, 0x0d, 0x4e, 0xac, 0xf4, 0x48, 0xcd, 0xc9, 0xc9, 0xf7, 0xcc, 0x2b, 0x28, 0x2d, 0x11, 0x12, 0xe1, 0x62, 0xcd, 0x00, 0xf1, 0x24, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x20,