From f9351bc3442b8fa0770f4b7e256d863b716da050 Mon Sep 17 00:00:00 2001 From: Doctor Vince Date: Tue, 23 May 2023 08:55:20 -0400 Subject: [PATCH] add mocks for Message and Stream interfaces (#124) * add mocks for Message and Stream interfaces * go mod tidy --- events/mock/events.go | 238 ++++++++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 3 +- 3 files changed, 240 insertions(+), 3 deletions(-) create mode 100644 events/mock/events.go diff --git a/events/mock/events.go b/events/mock/events.go new file mode 100644 index 0000000..4b58a3e --- /dev/null +++ b/events/mock/events.go @@ -0,0 +1,238 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: events.go + +// Package mock_events is a generated GoMock package. +package mock_events + +import ( + context "context" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + events "go.hollow.sh/toolbox/events" +) + +// MockStreamParameters is a mock of StreamParameters interface. +type MockStreamParameters struct { + ctrl *gomock.Controller + recorder *MockStreamParametersMockRecorder +} + +// MockStreamParametersMockRecorder is the mock recorder for MockStreamParameters. +type MockStreamParametersMockRecorder struct { + mock *MockStreamParameters +} + +// NewMockStreamParameters creates a new mock instance. +func NewMockStreamParameters(ctrl *gomock.Controller) *MockStreamParameters { + mock := &MockStreamParameters{ctrl: ctrl} + mock.recorder = &MockStreamParametersMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStreamParameters) EXPECT() *MockStreamParametersMockRecorder { + return m.recorder +} + +// MockStream is a mock of Stream interface. +type MockStream struct { + ctrl *gomock.Controller + recorder *MockStreamMockRecorder +} + +// MockStreamMockRecorder is the mock recorder for MockStream. +type MockStreamMockRecorder struct { + mock *MockStream +} + +// NewMockStream creates a new mock instance. +func NewMockStream(ctrl *gomock.Controller) *MockStream { + mock := &MockStream{ctrl: ctrl} + mock.recorder = &MockStreamMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStream) EXPECT() *MockStreamMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockStream) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockStreamMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockStream)(nil).Close)) +} + +// Open mocks base method. +func (m *MockStream) Open() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Open") + ret0, _ := ret[0].(error) + return ret0 +} + +// Open indicates an expected call of Open. +func (mr *MockStreamMockRecorder) Open() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Open", reflect.TypeOf((*MockStream)(nil).Open)) +} + +// Publish mocks base method. +func (m *MockStream) Publish(ctx context.Context, subject string, msg []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Publish", ctx, subject, msg) + ret0, _ := ret[0].(error) + return ret0 +} + +// Publish indicates an expected call of Publish. +func (mr *MockStreamMockRecorder) Publish(ctx, subject, msg interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Publish", reflect.TypeOf((*MockStream)(nil).Publish), ctx, subject, msg) +} + +// PullMsg mocks base method. +func (m *MockStream) PullMsg(ctx context.Context, batch int) ([]events.Message, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PullMsg", ctx, batch) + ret0, _ := ret[0].([]events.Message) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PullMsg indicates an expected call of PullMsg. +func (mr *MockStreamMockRecorder) PullMsg(ctx, batch interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PullMsg", reflect.TypeOf((*MockStream)(nil).PullMsg), ctx, batch) +} + +// Subscribe mocks base method. +func (m *MockStream) Subscribe(ctx context.Context) (events.MsgCh, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Subscribe", ctx) + ret0, _ := ret[0].(events.MsgCh) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Subscribe indicates an expected call of Subscribe. +func (mr *MockStreamMockRecorder) Subscribe(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Subscribe", reflect.TypeOf((*MockStream)(nil).Subscribe), ctx) +} + +// MockMessage is a mock of Message interface. +type MockMessage struct { + ctrl *gomock.Controller + recorder *MockMessageMockRecorder +} + +// MockMessageMockRecorder is the mock recorder for MockMessage. +type MockMessageMockRecorder struct { + mock *MockMessage +} + +// NewMockMessage creates a new mock instance. +func NewMockMessage(ctrl *gomock.Controller) *MockMessage { + mock := &MockMessage{ctrl: ctrl} + mock.recorder = &MockMessageMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockMessage) EXPECT() *MockMessageMockRecorder { + return m.recorder +} + +// Ack mocks base method. +func (m *MockMessage) Ack() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Ack") + ret0, _ := ret[0].(error) + return ret0 +} + +// Ack indicates an expected call of Ack. +func (mr *MockMessageMockRecorder) Ack() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ack", reflect.TypeOf((*MockMessage)(nil).Ack)) +} + +// Data mocks base method. +func (m *MockMessage) Data() []byte { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Data") + ret0, _ := ret[0].([]byte) + return ret0 +} + +// Data indicates an expected call of Data. +func (mr *MockMessageMockRecorder) Data() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Data", reflect.TypeOf((*MockMessage)(nil).Data)) +} + +// InProgress mocks base method. +func (m *MockMessage) InProgress() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "InProgress") + ret0, _ := ret[0].(error) + return ret0 +} + +// InProgress indicates an expected call of InProgress. +func (mr *MockMessageMockRecorder) InProgress() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InProgress", reflect.TypeOf((*MockMessage)(nil).InProgress)) +} + +// Nak mocks base method. +func (m *MockMessage) Nak() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Nak") + ret0, _ := ret[0].(error) + return ret0 +} + +// Nak indicates an expected call of Nak. +func (mr *MockMessageMockRecorder) Nak() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Nak", reflect.TypeOf((*MockMessage)(nil).Nak)) +} + +// Subject mocks base method. +func (m *MockMessage) Subject() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Subject") + ret0, _ := ret[0].(string) + return ret0 +} + +// Subject indicates an expected call of Subject. +func (mr *MockMessageMockRecorder) Subject() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Subject", reflect.TypeOf((*MockMessage)(nil).Subject)) +} + +// Term mocks base method. +func (m *MockMessage) Term() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Term") + ret0, _ := ret[0].(error) + return ret0 +} + +// Term indicates an expected call of Term. +func (mr *MockMessageMockRecorder) Term() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Term", reflect.TypeOf((*MockMessage)(nil).Term)) +} diff --git a/go.mod b/go.mod index d231465..f0d3e59 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.19 require ( github.com/gin-gonic/gin v1.9.0 + github.com/golang/mock v1.4.4 github.com/google/uuid v1.3.0 github.com/hashicorp/go-multierror v1.1.1 github.com/mitchellh/go-homedir v1.1.0 @@ -14,7 +15,6 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.8.2 - go.infratographer.com/x v0.0.3 go.uber.org/zap v1.24.0 golang.org/x/exp v0.0.0-20230321023759-10a507213a29 golang.org/x/net v0.8.0 diff --git a/go.sum b/go.sum index 835ad4d..8654fb3 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,7 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -248,8 +249,6 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.infratographer.com/x v0.0.3 h1:7txN1iBq1Ts4XF6Ea/9/LWK2vpTeXKnh+DjdJ1OLHVQ= -go.infratographer.com/x v0.0.3/go.mod h1:6qJTwrxN8O3X0v/v2/O7pZkq1T8V7rNDSnzZKJeEmRQ= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=