From 6583419d59ae3002263eace0193a13eb7e2be1b4 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 22 Jan 2025 12:13:15 +0100 Subject: [PATCH] refactor: replace custom mock implementations with mockery --- server/src/.mockery.yaml | 2 + server/src/api/notes_test.go | 75 ++-- server/src/api/votes_test.go | 59 ++- server/src/api/votings_test.go | 157 +++----- server/src/mocks/services/mock_Votings.go | 443 ++++++++++++++++++++++ 5 files changed, 537 insertions(+), 199 deletions(-) create mode 100644 server/src/mocks/services/mock_Votings.go diff --git a/server/src/.mockery.yaml b/server/src/.mockery.yaml index 75bec072d4..26372fde54 100644 --- a/server/src/.mockery.yaml +++ b/server/src/.mockery.yaml @@ -16,3 +16,5 @@ packages: all: true Notes: all: true + Votings: + all: true diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index 2916e5c4dd..eead457755 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -28,32 +28,17 @@ func TestNotesTestSuite(t *testing.T) { func (suite *NotesTestSuite) TestCreateNote() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "all ok", - expectedCode: http.StatusCreated, - }, - { - name: "api err", - expectedCode: http.StatusConflict, - err: &common.APIError{ - Err: errors.New("test"), - StatusCode: http.StatusConflict, - StatusText: "no", - ErrorText: "way", - }, - }, - { - name: "unexpected err", - expectedCode: http.StatusInternalServerError, - err: errors.New("oops"), - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusCreated, nil, false, false, nil). + Append("api err", http.StatusConflict, &common.APIError{ + Err: errors.New("test"), + StatusCode: http.StatusConflict, + StatusText: "no", + ErrorText: "way", + }, false, false, nil). + Append("unexpected err", http.StatusInternalServerError, errors.New("oops"), false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) noteMock := services.NewMockNotes(suite.T()) @@ -93,32 +78,17 @@ func (suite *NotesTestSuite) TestCreateNote() { } func (suite *NotesTestSuite) TestGetNote() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "all ok", - expectedCode: http.StatusOK, - }, - { - name: "api err", - expectedCode: http.StatusConflict, - err: &common.APIError{ - Err: errors.New("foo"), - StatusCode: http.StatusConflict, - StatusText: "no", - ErrorText: "way", - }, - }, - { - name: "unexpected err", - expectedCode: http.StatusInternalServerError, - err: errors.New("oops"), - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusOK, nil, false, false, nil). + Append("api err", http.StatusConflict, &common.APIError{ + Err: errors.New("test"), + StatusCode: http.StatusConflict, + StatusText: "no", + ErrorText: "way", + }, false, false, nil). + Append("unexpected err", http.StatusInternalServerError, errors.New("oops"), false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) noteMock := services.NewMockNotes(suite.T()) @@ -142,6 +112,7 @@ func (suite *NotesTestSuite) TestGetNote() { } } func (suite *NotesTestSuite) TestDeleteNote() { + tests := []struct { name string expectedCode int diff --git a/server/src/api/votes_test.go b/server/src/api/votes_test.go index 7ada9f1bd8..00cf253ba9 100644 --- a/server/src/api/votes_test.go +++ b/server/src/api/votes_test.go @@ -9,6 +9,7 @@ import ( "scrumlr.io/server/common/dto" "scrumlr.io/server/identifiers" "scrumlr.io/server/logger" + "scrumlr.io/server/mocks/services" "strings" "testing" @@ -27,48 +28,26 @@ func TestVoteTestSuite(t *testing.T) { func (suite *VoteTestSuite) TestAddVote() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "all ok", - expectedCode: http.StatusCreated, - }, - { - name: "specific error", - expectedCode: http.StatusTeapot, - err: &common.APIError{ - Err: errors.New("check"), - StatusCode: http.StatusTeapot, - StatusText: "teapot", - ErrorText: "Error", - }, - }, - { - name: "unexpected error", - expectedCode: http.StatusInternalServerError, - err: errors.New("teapot?"), - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusCreated, nil, false, false, nil). + Append("specific error", http.StatusTeapot, &common.APIError{ + Err: errors.New("check"), + StatusCode: http.StatusTeapot, + StatusText: "teapot", + ErrorText: "Error", + }, false, false, nil). + Append("unexpected error", http.StatusInternalServerError, errors.New("teapot?"), false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) - mock := new(VotingMock) + votingMock := services.NewMockVotings(suite.T()) boardId, _ := uuid.NewRandom() userId, _ := uuid.NewRandom() noteId, _ := uuid.NewRandom() - mock.On("AddVote", dto.VoteRequest{ - Board: boardId, - User: userId, - Note: noteId, - }).Return(&dto.Vote{ - Note: noteId, - }, tt.err) - s.votings = mock + s.votings = votingMock req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ "note": "%s" @@ -77,10 +56,18 @@ func (suite *VoteTestSuite) TestAddVote() { req.AddToContext(identifiers.BoardIdentifier, boardId). AddToContext(identifiers.UserIdentifier, userId) + votingMock.EXPECT().AddVote(req.req.Context(), dto.VoteRequest{ + Board: boardId, + User: userId, + Note: noteId, + }).Return(&dto.Vote{ + Note: noteId, + }, tt.err) + rr := httptest.NewRecorder() s.addVote(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + votingMock.AssertExpectations(suite.T()) }) } diff --git a/server/src/api/votings_test.go b/server/src/api/votings_test.go index b53430f57c..f950055bd2 100644 --- a/server/src/api/votings_test.go +++ b/server/src/api/votings_test.go @@ -1,60 +1,23 @@ package api import ( - "context" "errors" "net/http" "net/http/httptest" "scrumlr.io/server/common" "scrumlr.io/server/common/dto" - "scrumlr.io/server/common/filter" "scrumlr.io/server/identifiers" "scrumlr.io/server/logger" - "scrumlr.io/server/services" + "scrumlr.io/server/mocks/services" "strings" "testing" "github.com/google/uuid" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" "scrumlr.io/server/database/types" ) -type VotingMock struct { - services.Votings - mock.Mock -} - -func (m *VotingMock) AddVote(ctx context.Context, req dto.VoteRequest) (*dto.Vote, error) { - args := m.Called(req) - return args.Get(0).(*dto.Vote), args.Error(1) -} - -func (m *VotingMock) RemoveVote(ctx context.Context, req dto.VoteRequest) error { - args := m.Called(req) - return args.Error(0) -} - -func (m *VotingMock) GetVotes(ctx context.Context, f filter.VoteFilter) ([]*dto.Vote, error) { - args := m.Called(f.Board, f.Voting) - return args.Get(0).([]*dto.Vote), args.Error(1) -} -func (m *VotingMock) Get(ctx context.Context, boardID, id uuid.UUID) (*dto.Voting, error) { - args := m.Called(boardID, id) - return args.Get(0).(*dto.Voting), args.Error(1) -} - -func (m *VotingMock) Update(ctx context.Context, body dto.VotingUpdateRequest) (*dto.Voting, error) { - args := m.Called(body) - return args.Get(0).(*dto.Voting), args.Error(1) -} - -func (m *VotingMock) Create(ctx context.Context, body dto.VotingCreateRequest) (*dto.Voting, error) { - args := m.Called(body) - return args.Get(0).(*dto.Voting), args.Error(1) -} - type VotingTestSuite struct { suite.Suite } @@ -65,43 +28,18 @@ func TestVotingTestSuite(t *testing.T) { func (suite *VotingTestSuite) TestCreateVoting() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "all ok", - expectedCode: http.StatusCreated, - }, - { - name: "api error", - expectedCode: http.StatusBadRequest, - err: common.BadRequestError(errors.New("foo")), - }, - { - name: "unhandled error", - expectedCode: http.StatusInternalServerError, - err: errors.New("that was unexpected"), - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusCreated, nil, false, false, nil). + Append("api error", http.StatusBadRequest, common.BadRequestError(errors.New("foo")), false, false, nil). + Append("unhandled error", http.StatusInternalServerError, errors.New("that was unexpected"), false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) - mock := new(VotingMock) + votingMock := services.NewMockVotings(suite.T()) boardId, _ := uuid.NewRandom() - mock.On("Create", dto.VotingCreateRequest{ - VoteLimit: 4, - AllowMultipleVotes: false, - ShowVotesOfOthers: false, - Board: boardId, - }).Return(&dto.Voting{ - AllowMultipleVotes: false, - ShowVotesOfOthers: false, - }, tt.err) - - s.votings = mock + s.votings = votingMock req := NewTestRequestBuilder("POST", "/", strings.NewReader(`{ "voteLimit": 4, @@ -111,11 +49,21 @@ func (suite *VotingTestSuite) TestCreateVoting() { req.req = logger.InitTestLoggerRequest(req.Request()) req.AddToContext(identifiers.BoardIdentifier, boardId) + votingMock.EXPECT().Create(req.req.Context(), dto.VotingCreateRequest{ + VoteLimit: 4, + AllowMultipleVotes: false, + ShowVotesOfOthers: false, + Board: boardId, + }).Return(&dto.Voting{ + AllowMultipleVotes: false, + ShowVotesOfOthers: false, + }, tt.err) + rr := httptest.NewRecorder() s.createVoting(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) - mock.AssertNumberOfCalls(suite.T(), "Create", 1) + votingMock.AssertExpectations(suite.T()) + votingMock.AssertNumberOfCalls(suite.T(), "Create", 1) }) } @@ -123,38 +71,18 @@ func (suite *VotingTestSuite) TestCreateVoting() { func (suite *VotingTestSuite) TestUpdateVoting() { - tests := []struct { - name string - status types.VotingStatus - expectedCode int - err error - }{ - { - name: "all ok", - expectedCode: http.StatusOK, - }, - { - name: "unexpected error", - expectedCode: http.StatusInternalServerError, - err: errors.New("oops"), - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusOK, nil, false, false, nil). + Append("unexpected error", http.StatusInternalServerError, errors.New("oops"), false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) - mock := new(VotingMock) + votingMock := services.NewMockVotings(suite.T()) boardId, _ := uuid.NewRandom() votingId, _ := uuid.NewRandom() - mock.On("Update", dto.VotingUpdateRequest{ - Board: boardId, - ID: votingId, - Status: types.VotingStatusClosed, - }).Return(&dto.Voting{ - Status: types.VotingStatusClosed, - }, tt.err) - - s.votings = mock + s.votings = votingMock req := NewTestRequestBuilder("PUT", "/", strings.NewReader(`{ "status": "CLOSED" @@ -164,10 +92,18 @@ func (suite *VotingTestSuite) TestUpdateVoting() { AddToContext(identifiers.VotingIdentifier, votingId) rr := httptest.NewRecorder() + votingMock.EXPECT().Update(req.req.Context(), dto.VotingUpdateRequest{ + Board: boardId, + ID: votingId, + Status: types.VotingStatusClosed, + }).Return(&dto.Voting{ + Status: types.VotingStatusClosed, + }, tt.err) + s.updateVoting(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) - mock.AssertNumberOfCalls(suite.T(), "Update", 1) + votingMock.AssertExpectations(suite.T()) + votingMock.AssertNumberOfCalls(suite.T(), "Update", 1) }) } @@ -175,22 +111,21 @@ func (suite *VotingTestSuite) TestUpdateVoting() { func (suite *VotingTestSuite) TestGetVoting() { s := new(Server) - mock := new(VotingMock) - s.votings = mock + votingMock := services.NewMockVotings(suite.T()) + s.votings = votingMock boardId, _ := uuid.NewRandom() votingId, _ := uuid.NewRandom() - mock.On("Get", boardId, votingId).Return(&dto.Voting{ - ID: votingId, - Status: types.VotingStatusClosed, - }, nil) - req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.BoardIdentifier, boardId). AddToContext(identifiers.VotingIdentifier, votingId) rr := httptest.NewRecorder() - s.getVoting(rr, req.Request()) - mock.AssertExpectations(suite.T()) + votingMock.EXPECT().Get(req.req.Context(), boardId, votingId).Return(&dto.Voting{ + ID: votingId, + Status: types.VotingStatusClosed, + }, nil) + s.getVoting(rr, req.Request()) + votingMock.AssertExpectations(suite.T()) } diff --git a/server/src/mocks/services/mock_Votings.go b/server/src/mocks/services/mock_Votings.go new file mode 100644 index 0000000000..0d0a5d69be --- /dev/null +++ b/server/src/mocks/services/mock_Votings.go @@ -0,0 +1,443 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + dto "scrumlr.io/server/common/dto" + filter "scrumlr.io/server/common/filter" + + mock "github.com/stretchr/testify/mock" + + uuid "github.com/google/uuid" +) + +// MockVotings is an autogenerated mock type for the Votings type +type MockVotings struct { + mock.Mock +} + +type MockVotings_Expecter struct { + mock *mock.Mock +} + +func (_m *MockVotings) EXPECT() *MockVotings_Expecter { + return &MockVotings_Expecter{mock: &_m.Mock} +} + +// AddVote provides a mock function with given fields: ctx, req +func (_m *MockVotings) AddVote(ctx context.Context, req dto.VoteRequest) (*dto.Vote, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for AddVote") + } + + var r0 *dto.Vote + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.VoteRequest) (*dto.Vote, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.VoteRequest) *dto.Vote); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Vote) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.VoteRequest) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockVotings_AddVote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddVote' +type MockVotings_AddVote_Call struct { + *mock.Call +} + +// AddVote is a helper method to define mock.On call +// - ctx context.Context +// - req dto.VoteRequest +func (_e *MockVotings_Expecter) AddVote(ctx interface{}, req interface{}) *MockVotings_AddVote_Call { + return &MockVotings_AddVote_Call{Call: _e.mock.On("AddVote", ctx, req)} +} + +func (_c *MockVotings_AddVote_Call) Run(run func(ctx context.Context, req dto.VoteRequest)) *MockVotings_AddVote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.VoteRequest)) + }) + return _c +} + +func (_c *MockVotings_AddVote_Call) Return(_a0 *dto.Vote, _a1 error) *MockVotings_AddVote_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockVotings_AddVote_Call) RunAndReturn(run func(context.Context, dto.VoteRequest) (*dto.Vote, error)) *MockVotings_AddVote_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockVotings) Create(ctx context.Context, body dto.VotingCreateRequest) (*dto.Voting, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Voting + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.VotingCreateRequest) (*dto.Voting, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.VotingCreateRequest) *dto.Voting); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Voting) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.VotingCreateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockVotings_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockVotings_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.VotingCreateRequest +func (_e *MockVotings_Expecter) Create(ctx interface{}, body interface{}) *MockVotings_Create_Call { + return &MockVotings_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockVotings_Create_Call) Run(run func(ctx context.Context, body dto.VotingCreateRequest)) *MockVotings_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.VotingCreateRequest)) + }) + return _c +} + +func (_c *MockVotings_Create_Call) Return(_a0 *dto.Voting, _a1 error) *MockVotings_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockVotings_Create_Call) RunAndReturn(run func(context.Context, dto.VotingCreateRequest) (*dto.Voting, error)) *MockVotings_Create_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, board, id +func (_m *MockVotings) Get(ctx context.Context, board uuid.UUID, id uuid.UUID) (*dto.Voting, error) { + ret := _m.Called(ctx, board, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Voting + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.Voting, error)); ok { + return rf(ctx, board, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.Voting); ok { + r0 = rf(ctx, board, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Voting) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, board, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockVotings_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockVotings_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - id uuid.UUID +func (_e *MockVotings_Expecter) Get(ctx interface{}, board interface{}, id interface{}) *MockVotings_Get_Call { + return &MockVotings_Get_Call{Call: _e.mock.On("Get", ctx, board, id)} +} + +func (_c *MockVotings_Get_Call) Run(run func(ctx context.Context, board uuid.UUID, id uuid.UUID)) *MockVotings_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID)) + }) + return _c +} + +func (_c *MockVotings_Get_Call) Return(_a0 *dto.Voting, _a1 error) *MockVotings_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockVotings_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.Voting, error)) *MockVotings_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetVotes provides a mock function with given fields: ctx, f +func (_m *MockVotings) GetVotes(ctx context.Context, f filter.VoteFilter) ([]*dto.Vote, error) { + ret := _m.Called(ctx, f) + + if len(ret) == 0 { + panic("no return value specified for GetVotes") + } + + var r0 []*dto.Vote + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, filter.VoteFilter) ([]*dto.Vote, error)); ok { + return rf(ctx, f) + } + if rf, ok := ret.Get(0).(func(context.Context, filter.VoteFilter) []*dto.Vote); ok { + r0 = rf(ctx, f) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Vote) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, filter.VoteFilter) error); ok { + r1 = rf(ctx, f) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockVotings_GetVotes_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetVotes' +type MockVotings_GetVotes_Call struct { + *mock.Call +} + +// GetVotes is a helper method to define mock.On call +// - ctx context.Context +// - f filter.VoteFilter +func (_e *MockVotings_Expecter) GetVotes(ctx interface{}, f interface{}) *MockVotings_GetVotes_Call { + return &MockVotings_GetVotes_Call{Call: _e.mock.On("GetVotes", ctx, f)} +} + +func (_c *MockVotings_GetVotes_Call) Run(run func(ctx context.Context, f filter.VoteFilter)) *MockVotings_GetVotes_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(filter.VoteFilter)) + }) + return _c +} + +func (_c *MockVotings_GetVotes_Call) Return(_a0 []*dto.Vote, _a1 error) *MockVotings_GetVotes_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockVotings_GetVotes_Call) RunAndReturn(run func(context.Context, filter.VoteFilter) ([]*dto.Vote, error)) *MockVotings_GetVotes_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, board +func (_m *MockVotings) List(ctx context.Context, board uuid.UUID) ([]*dto.Voting, error) { + ret := _m.Called(ctx, board) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.Voting + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Voting, error)); ok { + return rf(ctx, board) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Voting); ok { + r0 = rf(ctx, board) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Voting) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, board) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockVotings_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockVotings_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +func (_e *MockVotings_Expecter) List(ctx interface{}, board interface{}) *MockVotings_List_Call { + return &MockVotings_List_Call{Call: _e.mock.On("List", ctx, board)} +} + +func (_c *MockVotings_List_Call) Run(run func(ctx context.Context, board uuid.UUID)) *MockVotings_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockVotings_List_Call) Return(_a0 []*dto.Voting, _a1 error) *MockVotings_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockVotings_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Voting, error)) *MockVotings_List_Call { + _c.Call.Return(run) + return _c +} + +// RemoveVote provides a mock function with given fields: ctx, req +func (_m *MockVotings) RemoveVote(ctx context.Context, req dto.VoteRequest) error { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for RemoveVote") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dto.VoteRequest) error); ok { + r0 = rf(ctx, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockVotings_RemoveVote_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveVote' +type MockVotings_RemoveVote_Call struct { + *mock.Call +} + +// RemoveVote is a helper method to define mock.On call +// - ctx context.Context +// - req dto.VoteRequest +func (_e *MockVotings_Expecter) RemoveVote(ctx interface{}, req interface{}) *MockVotings_RemoveVote_Call { + return &MockVotings_RemoveVote_Call{Call: _e.mock.On("RemoveVote", ctx, req)} +} + +func (_c *MockVotings_RemoveVote_Call) Run(run func(ctx context.Context, req dto.VoteRequest)) *MockVotings_RemoveVote_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.VoteRequest)) + }) + return _c +} + +func (_c *MockVotings_RemoveVote_Call) Return(_a0 error) *MockVotings_RemoveVote_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockVotings_RemoveVote_Call) RunAndReturn(run func(context.Context, dto.VoteRequest) error) *MockVotings_RemoveVote_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockVotings) Update(ctx context.Context, body dto.VotingUpdateRequest) (*dto.Voting, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Voting + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.VotingUpdateRequest) (*dto.Voting, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.VotingUpdateRequest) *dto.Voting); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Voting) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.VotingUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockVotings_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockVotings_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.VotingUpdateRequest +func (_e *MockVotings_Expecter) Update(ctx interface{}, body interface{}) *MockVotings_Update_Call { + return &MockVotings_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockVotings_Update_Call) Run(run func(ctx context.Context, body dto.VotingUpdateRequest)) *MockVotings_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.VotingUpdateRequest)) + }) + return _c +} + +func (_c *MockVotings_Update_Call) Return(_a0 *dto.Voting, _a1 error) *MockVotings_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockVotings_Update_Call) RunAndReturn(run func(context.Context, dto.VotingUpdateRequest) (*dto.Voting, error)) *MockVotings_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockVotings creates a new instance of MockVotings. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockVotings(t interface { + mock.TestingT + Cleanup(func()) +}) *MockVotings { + mock := &MockVotings{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}