From 1c0c734b40e126101910f13816085b9ebe6f5456 Mon Sep 17 00:00:00 2001 From: Mateo Date: Wed, 22 May 2024 10:01:07 +0200 Subject: [PATCH 01/27] basic test cases for api/columns --- server/src/api/columns_test.go | 351 +++++++++++++++++++++++++++++++++ 1 file changed, 351 insertions(+) create mode 100644 server/src/api/columns_test.go diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go new file mode 100644 index 0000000000..27d972566e --- /dev/null +++ b/server/src/api/columns_test.go @@ -0,0 +1,351 @@ +package api + +import ( + "context" + "errors" + "fmt" + "github.com/google/uuid" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/database/types" + "scrumlr.io/server/identifiers" + "scrumlr.io/server/services" + "strings" + "testing" +) + +type BoardMock struct { + services.Boards + mock.Mock +} + +func (m *BoardMock) CreateColumn(ctx context.Context, req dto.ColumnRequest) (*dto.Column, error) { + args := m.Called(req) + return args.Get(0).(*dto.Column), args.Error(1) +} + +func (m *BoardMock) DeleteColumn(ctx context.Context, board, column, user uuid.UUID) error { + args := m.Called(board, column, user) + return args.Error(0) +} + +func (m *BoardMock) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { + args := m.Called(body) + return args.Get(0).(*dto.Column), args.Error(1) +} + +func (m *BoardMock) GetColumn(ctx context.Context, boardID, columnID uuid.UUID) (*dto.Column, error) { + args := m.Called(boardID, columnID) + return args.Get(0).(*dto.Column), args.Error(1) +} + +func (m *BoardMock) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*dto.Column, error) { + args := m.Called(boardID) + return args.Get(0).([]*dto.Column), args.Error(1) +} + +type ColumnTestSuite struct { + suite.Suite +} + +func TestColumnTestSuite(t *testing.T) { + suite.Run(t, new(ColumnTestSuite)) +} + +func (suite *ColumnTestSuite) TestCreateColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful created column", + expectedCode: http.StatusCreated, + }, + { + name: "Failed creating column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + name := "TestColumn" + color := types.Color("backlog-blue") + visible := true + index := 0 + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + + mock.On("CreateColumn", dto.ColumnRequest{ + Name: name, + Color: color, + Visible: &visible, + Index: &index, + Board: boardID, + User: userID, + }).Return(&dto.Column{ + ID: uuid.UUID{}, + Name: name, + Color: color, + Visible: visible, + Index: index, + }, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( + `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, + ))).AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID) + rr := httptest.NewRecorder() + + s.createColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestDeleteColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful deleted column", + expectedCode: http.StatusNoContent, + }, + { + name: "Failed deleting column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + + mock.On("DeleteColumn", boardID, columnID, userID).Return(tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("DEL", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + s.deleteColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestUpdateColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful updated column", + expectedCode: http.StatusOK, + }, + { + name: "Failed updating column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "TestColumn" + color := types.Color("online-orange") + visible := false + index := 0 + + mock.On("UpdateColumn", dto.ColumnUpdateRequest{ + Name: colName, + Color: color, + Visible: visible, + Index: index, + ID: columnID, + Board: boardID, + }).Return(&dto.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + }, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("PUT", "/", strings.NewReader( + fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + s.updateColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestGetColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful get column", + expectedCode: http.StatusOK, + }, + { + name: "Failed getting column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "Updated Column Name" + color := types.Color("online-orange") + visible := false + index := 0 + + column := &dto.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + } + + mock.On("GetColumn", boardID, columnID).Return(column, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + s.getColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestGetColumns() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful get columns", + expectedCode: http.StatusOK, + }, + { + name: "Failed getting columns", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get columns", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "TestColumn" + color := types.Color("online-orange") + visible := false + index := 0 + + column := &dto.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + } + + mock.On("ListColumns", boardID).Return([]*dto.Column{column}, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + rr := httptest.NewRecorder() + + s.getColumns(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} From 38a9f81be7fd71d0b28ba8ce862c4b22708dc7dd Mon Sep 17 00:00:00 2001 From: Mateo Date: Thu, 23 May 2024 09:10:48 +0200 Subject: [PATCH 02/27] add unit tests for board --- server/src/api/boards.go | 2 +- server/src/api/boards_test.go | 253 ++++++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 server/src/api/boards_test.go diff --git a/server/src/api/boards.go b/server/src/api/boards.go index 3a33156218..03b85fc1ac 100644 --- a/server/src/api/boards.go +++ b/server/src/api/boards.go @@ -35,7 +35,7 @@ func (s *Server) createBoard(w http.ResponseWriter, r *http.Request) { b, err := s.boards.Create(r.Context(), body) if err != nil { - common.Throw(w, r, common.BadRequestError(err)) + common.Throw(w, r, err) return } diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go new file mode 100644 index 0000000000..3c747debd7 --- /dev/null +++ b/server/src/api/boards_test.go @@ -0,0 +1,253 @@ +package api + +import ( + "context" + "errors" + "fmt" + "github.com/google/uuid" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/database/types" + "scrumlr.io/server/identifiers" + "strings" + "testing" +) + +func (m *BoardMock) Create(ctx context.Context, req dto.CreateBoardRequest) (*dto.Board, error) { + args := m.Called(req) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) Delete(ctx context.Context, boardID uuid.UUID) error { + args := m.Called(boardID) + return args.Error(0) +} + +func (m *BoardMock) BoardOverview(ctx context.Context, boardIDs []uuid.UUID, userID uuid.UUID) ([]*dto.BoardOverview, error) { + args := m.Called(boardIDs, userID) + return args.Get(0).([]*dto.BoardOverview), args.Error(1) +} + +func (m *BoardMock) Get(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) Update(ctx context.Context, req dto.BoardUpdateRequest) (*dto.Board, error) { + args := m.Called(req) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) SetTimer(ctx context.Context, boardID uuid.UUID, minutes uint8) (*dto.Board, error) { + args := m.Called(boardID, minutes) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) DeleteTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) IncrementTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) FullBoard(ctx context.Context, boardID uuid.UUID) (*dto.Board, []*dto.BoardSessionRequest, []*dto.BoardSession, []*dto.Column, []*dto.Note, []*dto.Reaction, []*dto.Voting, []*dto.Vote, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Get(1).([]*dto.BoardSessionRequest), args.Get(2).([]*dto.BoardSession), args.Get(3).([]*dto.Column), args.Get(4).([]*dto.Note), args.Get(5).([]*dto.Reaction), args.Get(6).([]*dto.Voting), args.Get(7).([]*dto.Vote), args.Error(8) +} + +type BoardTestSuite struct { + suite.Suite +} + +func TestBoardTestSuite(t *testing.T) { + suite.Run(t, new(BoardTestSuite)) +} + +func (suite *BoardTestSuite) TestCreateBoard() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully create board", + expectedCode: http.StatusCreated, + err: nil, + }, + { + name: "Failed creating board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to create board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + accessPolicy := types.AccessPolicyPublic + visible := true + ownerID, _ := uuid.NewRandom() + colName := "Lean Coffee" + color := types.Color("backlog-blue") + boardID, _ := uuid.NewRandom() + + mock.On("Create", dto.CreateBoardRequest{ + Name: nil, + Description: nil, + AccessPolicy: accessPolicy, + Passphrase: nil, + Columns: []dto.ColumnRequest{ + { + Name: colName, + Color: color, + Visible: &visible, + Index: nil, + Board: uuid.Nil, + User: uuid.Nil, + }, + }, + Owner: ownerID, + }).Return(&dto.Board{ + ID: boardID, + Name: nil, + Description: nil, + AccessPolicy: accessPolicy, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, tt.err) + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(` { + "accessPolicy": "%s", + "columns": [ + { + "name": "%s", + "visible": %v, + "color": "%s" + } + ] + }`, accessPolicy, colName, visible, color))). + AddToContext(identifiers.UserIdentifier, ownerID) + + rr := httptest.NewRecorder() + + s.createBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestDeleteBoard() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully deleted board", + expectedCode: http.StatusNoContent, + err: nil, + }, + { + name: "Failed deleting board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to delete board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("Delete", boardID).Return(tt.err) + + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.deleteBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestGetBoards() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully deleted board", + expectedCode: http.StatusNoContent, + err: nil, + }, + { + name: "Failed deleting board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to delete board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("Delete", boardID).Return(tt.err) + + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.deleteBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} From 2315213ccdde30b2ee6188291a67f4e1506b5430 Mon Sep 17 00:00:00 2001 From: Mateo Date: Fri, 24 May 2024 14:26:28 +0200 Subject: [PATCH 03/27] add unit tests for board --- server/src/api/boards_test.go | 550 +++++++++++++++++++++++++++++++++- server/src/api/notes_test.go | 38 +-- 2 files changed, 562 insertions(+), 26 deletions(-) diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go index 3c747debd7..2cf968f92f 100644 --- a/server/src/api/boards_test.go +++ b/server/src/api/boards_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/go-chi/chi/v5" "github.com/google/uuid" "github.com/stretchr/testify/suite" "net/http" @@ -14,6 +15,7 @@ import ( "scrumlr.io/server/identifiers" "strings" "testing" + "time" ) func (m *BoardMock) Create(ctx context.Context, req dto.CreateBoardRequest) (*dto.Board, error) { @@ -36,6 +38,11 @@ func (m *BoardMock) Get(ctx context.Context, boardID uuid.UUID) (*dto.Board, err return args.Get(0).(*dto.Board), args.Error(1) } +func (m *BoardMock) GetBoards(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) { + args := m.Called(userID) + return args.Get(0).([]uuid.UUID), args.Error(1) +} + func (m *BoardMock) Update(ctx context.Context, req dto.BoardUpdateRequest) (*dto.Board, error) { args := m.Called(req) return args.Get(0).(*dto.Board), args.Error(1) @@ -213,18 +220,120 @@ func (suite *BoardTestSuite) TestGetBoards() { err error }{ { - name: "Successfully deleted board", - expectedCode: http.StatusNoContent, + name: "Successfully received boards", + expectedCode: http.StatusOK, err: nil, }, { - name: "Failed deleting board", + name: "Failed receiving boards", expectedCode: http.StatusInternalServerError, err: &common.APIError{ - Err: errors.New("failed to delete board"), + Err: errors.New("failed to receive boards"), StatusCode: http.StatusInternalServerError, StatusText: "no", - ErrorText: "Could not delete board", + ErrorText: "Could not receive boards", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + userID, _ := uuid.NewRandom() + + boardName := "Test Name" + boardDescription := "Test Description" + firstBoard := &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: "", + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + } + + boardName = "Test Board" + boardDescription = "Description for second board" + secondBoard := &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: "", + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + } + boardIDs := []uuid.UUID{firstBoard.ID, secondBoard.ID} + + mock.On("GetBoards", userID).Return(boardIDs, tt.err) + if tt.err == nil { + mock.On("BoardOverview", boardIDs, userID).Return([]*dto.BoardOverview{{ + Board: firstBoard, + Columns: 1, + CreatedAt: time.Time{}, + Participants: 3, + }, + { + Board: secondBoard, + Columns: 2, + CreatedAt: time.Time{}, + Participants: 4, + }, + }, tt.err) + } + + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.UserIdentifier, userID) + + rr := httptest.NewRecorder() + + s.getBoards(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestGetBoard() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully received boards", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed receiving boards", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to receive boards"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not receive boards", }, }, } @@ -237,14 +346,441 @@ func (suite *BoardTestSuite) TestGetBoards() { boardID, _ := uuid.NewRandom() - mock.On("Delete", boardID).Return(tt.err) + boardName := "Test Name" + boardDescription := "Test Description" + board := &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: "", + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + } + + mock.On("Get", boardID).Return(board, tt.err) req := NewTestRequestBuilder("POST", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) rr := httptest.NewRecorder() - s.deleteBoard(rr, req.Request()) + s.getBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestJoinBoard() { + boardName := "Test Name" + boardDescription := "Test Description" + salt := "z9YcpBno6azI2ueA" + passphrase := common.Sha512BySalt("123", salt) + + tests := []struct { + name string + expectedCode int + err error + sessionExists bool + sessionRequestExists bool + board *dto.Board + }{ + { + name: "Successfully join board", + expectedCode: http.StatusSeeOther, + err: nil, + sessionExists: true, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyPublic, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, + }, + { + name: "Failed joining board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to join board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not join board", + }, + sessionExists: true, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyPublic, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, + }, + { + name: "Successfully joined board without session", + expectedCode: http.StatusCreated, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyPublic, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, + }, { + name: "Successfully joined board with passphrase", + expectedCode: http.StatusCreated, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyByPassphrase, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: &passphrase, + Salt: &salt, + }, + }, + { + name: "Successfully join board by invite with existing session request", + expectedCode: http.StatusSeeOther, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyByInvite, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: &passphrase, + Salt: &salt, + }, + sessionRequestExists: true, + }, + { + name: "Successfully join board by invite with existing session request", + expectedCode: http.StatusSeeOther, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyByInvite, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: &passphrase, + Salt: &salt, + }, + sessionRequestExists: false, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + sessionMock := new(SessionsMock) + s.boards = mock + s.sessions = sessionMock + + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + sessionMock.On("SessionExists", boardID, userID).Return(tt.sessionExists, nil) + if tt.sessionExists { + sessionMock.On("ParticipantBanned", boardID, userID).Return(false, tt.err) + } else { + //sessionMock.On("SessionExists", boardID, userID).Return(false, nil) + mock.On("Get", boardID).Return(tt.board, tt.err) + } + + if tt.board.AccessPolicy == types.AccessPolicyByInvite { + sessionMock.On("SessionRequestExists", boardID, userID).Return(tt.sessionRequestExists, tt.err) + if !tt.sessionRequestExists { + sessionMock.On("CreateSessionRequest", boardID, userID).Return(new(dto.BoardSessionRequest), tt.err) + } + } else { + if !tt.sessionExists { + sessionMock.On("Create", boardID, userID).Return(new(dto.BoardSession), tt.err) + } + + } + + req := NewTestRequestBuilder("POST", fmt.Sprintf("/%s", boardID), strings.NewReader(`{"passphrase": "123"}`)). + AddToContext(identifiers.UserIdentifier, userID) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + + rr := httptest.NewRecorder() + + s.joinBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + sessionMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestUpdateBoards() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully updated boards", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed updating board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to update board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + newName := "UpdatedName" + newDescription := "UpdatedDescription" + boardID, _ := uuid.NewRandom() + accessPolicy := types.AccessPolicyPublic + boardReq := dto.BoardUpdateRequest{ + Name: &newName, + Description: &newDescription, + AccessPolicy: &accessPolicy, + ID: boardID, + } + + mock.On("Update", boardReq).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("PUT", fmt.Sprintf("/%s", boardID), strings.NewReader(fmt.Sprintf(`{ + "id": "%s", + "name": "%s", + "description": "%s", + "accessPolicy": "PUBLIC" + }`, boardID, newName, newDescription))). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.updateBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestSetTimer() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully set timer", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed set timer", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to set timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not set timer", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + minutes := uint8(4) + + mock.On("SetTimer", boardID, minutes).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("PUT", "/timer", strings.NewReader(fmt.Sprintf(`{"minutes": %d}`, minutes))). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.setTimer(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestDeleteTimer() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully deleted timer", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed deleting timer", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to delete timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete timer", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("DeleteTimer", boardID).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("DEL", "/timer", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.deleteTimer(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestIncrementTimer() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully increment timer", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed incrementing timer", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to increment timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not increment timer", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("IncrementTimer", boardID).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("POST", "/timer/increment", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.incrementTimer(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) mock.AssertExpectations(suite.T()) diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index ec4cecda5c..ff22c04b2d 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -49,78 +49,78 @@ type SessionsMock struct { } func (m *SessionsMock) SessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } func (m *SessionsMock) ParticipantBanned(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } func (m *SessionsMock) Connect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Error(0) } func (m *SessionsMock) Create(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSession), args.Error(1) } // Add other missing methods here func (m *SessionsMock) Get(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSession), args.Error(1) } func (m *SessionsMock) Update(ctx context.Context, body dto.BoardSessionUpdateRequest) (*dto.BoardSession, error) { - args := m.Called(ctx, body) + args := m.Called(body) return args.Get(0).(*dto.BoardSession), args.Error(1) } func (m *SessionsMock) UpdateAll(ctx context.Context, body dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error) { - args := m.Called(ctx, body) + args := m.Called(body) return args.Get(0).([]*dto.BoardSession), args.Error(1) } func (m *SessionsMock) List(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter) ([]*dto.BoardSession, error) { - args := m.Called(ctx, boardID, f) + args := m.Called(boardID, f) return args.Get(0).([]*dto.BoardSession), args.Error(1) } func (m *SessionsMock) Disconnect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Error(0) } func (m *SessionsMock) GetSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) CreateSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) ListSessionRequest(ctx context.Context, boardID uuid.UUID, statusQuery string) ([]*dto.BoardSessionRequest, error) { - args := m.Called(ctx, boardID, statusQuery) + args := m.Called(boardID, statusQuery) return args.Get(0).([]*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) UpdateSessionRequest(ctx context.Context, body dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error) { - args := m.Called(ctx, body) + args := m.Called(body) return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) ModeratorSessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } func (m *SessionsMock) SessionRequestExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } @@ -298,13 +298,13 @@ func (suite *NotesTestSuite) TestDeleteNote() { }, nil) // Mock the SessionExists method - sessionMock.On("SessionExists", mock.Anything, boardID, userID).Return(true, nil) + sessionMock.On("SessionExists", boardID, userID).Return(true, nil) // Mock the ModeratorSessionExists method - sessionMock.On("ModeratorSessionExists", mock.Anything, boardID, userID).Return(true, nil) + sessionMock.On("ModeratorSessionExists", boardID, userID).Return(true, nil) // Mock the ParticipantBanned method - sessionMock.On("ParticipantBanned", mock.Anything, boardID, userID).Return(false, nil) + sessionMock.On("ParticipantBanned", boardID, userID).Return(false, nil) if tt.isLocked { noteMock.On("Delete", mock.Anything, mock.Anything).Return(nil) @@ -313,7 +313,7 @@ func (suite *NotesTestSuite) TestDeleteNote() { ID: boardID, IsLocked: tt.isLocked, }, tt.err) - noteMock.On("Delete", mock.Anything, mock.Anything).Return(tt.err) + noteMock.On("Delete", mock.Anything).Return(tt.err) } req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) From 73acd72a8786760a28317111a0968ba9f48c94ea Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 11:32:33 +0100 Subject: [PATCH 04/27] add unit tests for board --- server/src/api/boards_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go index 2cf968f92f..cc889e4ae8 100644 --- a/server/src/api/boards_test.go +++ b/server/src/api/boards_test.go @@ -136,7 +136,7 @@ func (suite *BoardTestSuite) TestCreateBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -255,7 +255,7 @@ func (suite *BoardTestSuite) TestGetBoards() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -275,7 +275,7 @@ func (suite *BoardTestSuite) TestGetBoards() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -357,7 +357,7 @@ func (suite *BoardTestSuite) TestGetBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -409,7 +409,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -437,7 +437,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -460,7 +460,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -482,7 +482,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -505,7 +505,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -529,7 +529,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, From 21ad79d5658e5839d9836bae7ebf25cf4f69f79f Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 15:59:31 +0100 Subject: [PATCH 05/27] chore: The first steps for the transition to mockery in the API layer have been completed. Next, we still need to implement mockery in all API tests and delete the manual interfaces steps to todo: * remove old manual written interface mock implementation, * adapt api tests, * enhance readme for mockery setup. --- server/src/.mockery.yaml | 13 + server/src/api/boards_test.go | 771 +++++++------------------ server/src/api/columns_test.go | 108 ++-- server/src/api/request_builder.go | 1 - server/src/api/test_content_builder.go | 81 +++ 5 files changed, 348 insertions(+), 626 deletions(-) create mode 100644 server/src/.mockery.yaml create mode 100644 server/src/api/test_content_builder.go diff --git a/server/src/.mockery.yaml b/server/src/.mockery.yaml new file mode 100644 index 0000000000..c26a0bf520 --- /dev/null +++ b/server/src/.mockery.yaml @@ -0,0 +1,13 @@ +with-expecter: true +dir: mocks/{{ replaceAll .InterfaceDirRelative "internal" "internal_" }} +mockname: "Mock{{.InterfaceName}}" +outpkg: "{{.PackageName}}" +filename: "mock_{{.InterfaceName}}.go" +resolve-type-alias: false +issue-845-fix: true +packages: + # configuration on package level + scrumlr.io/server/services: + config: + # generate for all interfaces in services a mock (for example: mock_Boards) + all: true diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go index cc889e4ae8..69da450fa5 100644 --- a/server/src/api/boards_test.go +++ b/server/src/api/boards_test.go @@ -1,7 +1,6 @@ package api import ( - "context" "errors" "fmt" "github.com/go-chi/chi/v5" @@ -13,61 +12,12 @@ import ( "scrumlr.io/server/common/dto" "scrumlr.io/server/database/types" "scrumlr.io/server/identifiers" + "scrumlr.io/server/mocks/services" "strings" "testing" "time" ) -func (m *BoardMock) Create(ctx context.Context, req dto.CreateBoardRequest) (*dto.Board, error) { - args := m.Called(req) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) Delete(ctx context.Context, boardID uuid.UUID) error { - args := m.Called(boardID) - return args.Error(0) -} - -func (m *BoardMock) BoardOverview(ctx context.Context, boardIDs []uuid.UUID, userID uuid.UUID) ([]*dto.BoardOverview, error) { - args := m.Called(boardIDs, userID) - return args.Get(0).([]*dto.BoardOverview), args.Error(1) -} - -func (m *BoardMock) Get(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) GetBoards(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) { - args := m.Called(userID) - return args.Get(0).([]uuid.UUID), args.Error(1) -} - -func (m *BoardMock) Update(ctx context.Context, req dto.BoardUpdateRequest) (*dto.Board, error) { - args := m.Called(req) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) SetTimer(ctx context.Context, boardID uuid.UUID, minutes uint8) (*dto.Board, error) { - args := m.Called(boardID, minutes) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) DeleteTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) IncrementTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) FullBoard(ctx context.Context, boardID uuid.UUID) (*dto.Board, []*dto.BoardSessionRequest, []*dto.BoardSession, []*dto.Column, []*dto.Note, []*dto.Reaction, []*dto.Voting, []*dto.Vote, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Get(1).([]*dto.BoardSessionRequest), args.Get(2).([]*dto.BoardSession), args.Get(3).([]*dto.Column), args.Get(4).([]*dto.Note), args.Get(5).([]*dto.Reaction), args.Get(6).([]*dto.Voting), args.Get(7).([]*dto.Vote), args.Error(8) -} - type BoardTestSuite struct { suite.Suite } @@ -76,42 +26,62 @@ func TestBoardTestSuite(t *testing.T) { suite.Run(t, new(BoardTestSuite)) } -func (suite *BoardTestSuite) TestCreateBoard() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully create board", - expectedCode: http.StatusCreated, - err: nil, - }, - { - name: "Failed creating board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to create board"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not create board", - }, - }, +func (suite *BoardTestSuite) createBoard(boardName *string, boardDescription *string, accessPolicy types.AccessPolicy, passphrase *string, salt *string) *dto.Board { + return &dto.Board{ + ID: uuid.New(), + Name: boardName, + Description: boardDescription, + AccessPolicy: accessPolicy, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + IsLocked: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: passphrase, + Salt: salt, } +} - for _, tt := range tests { - suite.Run(tt.name, func() { +func (suite *BoardTestSuite) TestCreateBoard() { + + testParameterBundles := *TestParameterBundles{}. + Append("Successfully create board", http.StatusCreated, nil, false, false, nil). + Append("Failed creating board", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to create board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create board", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock + boardMock := services.NewMockBoards(suite.T()) + + s.boards = boardMock accessPolicy := types.AccessPolicyPublic visible := true - ownerID, _ := uuid.NewRandom() colName := "Lean Coffee" color := types.Color("backlog-blue") - boardID, _ := uuid.NewRandom() + ownerID := uuid.New() - mock.On("Create", dto.CreateBoardRequest{ + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(` { + "accessPolicy": "%s", + "columns": [ + { + "name": "%s", + "visible": %v, + "color": "%s" + } + ] + }`, accessPolicy, colName, visible, color))). + AddToContext(identifiers.UserIdentifier, ownerID) + + boardMock.EXPECT().Create(req.req.Context(), dto.CreateBoardRequest{ Name: nil, Description: nil, AccessPolicy: accessPolicy, @@ -127,167 +97,83 @@ func (suite *BoardTestSuite) TestCreateBoard() { }, }, Owner: ownerID, - }).Return(&dto.Board{ - ID: boardID, - Name: nil, - Description: nil, - AccessPolicy: accessPolicy, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, tt.err) - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(` { - "accessPolicy": "%s", - "columns": [ - { - "name": "%s", - "visible": %v, - "color": "%s" - } - ] - }`, accessPolicy, colName, visible, color))). - AddToContext(identifiers.UserIdentifier, ownerID) + }).Return(suite.createBoard(nil, nil, accessPolicy, nil, nil), te.err) rr := httptest.NewRecorder() s.createBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestDeleteBoard() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully deleted board", - expectedCode: http.StatusNoContent, - err: nil, - }, - { - name: "Failed deleting board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to delete board"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not delete board", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully deleted board", http.StatusNoContent, nil, false, false, nil). + Append("Failed deleting board", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to delete board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete board", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() - - mock.On("Delete", boardID).Return(tt.err) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() req := NewTestRequestBuilder("POST", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().Delete(req.req.Context(), boardID).Return(te.err) rr := httptest.NewRecorder() s.deleteBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestGetBoards() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully received boards", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed receiving boards", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to receive boards"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not receive boards", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully received boards", http.StatusOK, nil, false, false, nil). + Append("Failed receiving boards", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to receive boards"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not receive boards", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - userID, _ := uuid.NewRandom() + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + userID := uuid.New() boardName := "Test Name" boardDescription := "Test Description" - firstBoard := &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: "", - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - } + firstBoard := suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil) boardName = "Test Board" boardDescription = "Description for second board" - secondBoard := &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: "", - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - } + secondBoard := suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil) boardIDs := []uuid.UUID{firstBoard.ID, secondBoard.ID} - mock.On("GetBoards", userID).Return(boardIDs, tt.err) - if tt.err == nil { - mock.On("BoardOverview", boardIDs, userID).Return([]*dto.BoardOverview{{ + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.UserIdentifier, userID) + + boardMock.EXPECT().GetBoards(req.req.Context(), userID).Return(boardIDs, te.err) + if te.err == nil { + boardMock.EXPECT().BoardOverview(req.req.Context(), boardIDs, userID).Return([]*dto.BoardOverview{{ Board: firstBoard, Columns: 1, CreatedAt: time.Time{}, @@ -299,84 +185,52 @@ func (suite *BoardTestSuite) TestGetBoards() { CreatedAt: time.Time{}, Participants: 4, }, - }, tt.err) + }, te.err) } - req := NewTestRequestBuilder("POST", "/", nil). - AddToContext(identifiers.UserIdentifier, userID) - rr := httptest.NewRecorder() s.getBoards(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestGetBoard() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully received boards", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed receiving boards", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to receive boards"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not receive boards", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully received boards", http.StatusOK, nil, false, false, nil). + Append("Failed receiving boards", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to receive boards"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not receive boards", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() boardName := "Test Name" boardDescription := "Test Description" - board := &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: "", - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - } - - mock.On("Get", boardID).Return(board, tt.err) + board := suite.createBoard(&boardName, &boardDescription, "", nil, nil) req := NewTestRequestBuilder("POST", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().Get(req.req.Context(), boardID).Return(board, te.err) + rr := httptest.NewRecorder() s.getBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } @@ -387,239 +241,87 @@ func (suite *BoardTestSuite) TestJoinBoard() { salt := "z9YcpBno6azI2ueA" passphrase := common.Sha512BySalt("123", salt) - tests := []struct { - name string - expectedCode int - err error - sessionExists bool - sessionRequestExists bool - board *dto.Board - }{ - { - name: "Successfully join board", - expectedCode: http.StatusSeeOther, - err: nil, - sessionExists: true, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyPublic, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, - }, - { - name: "Failed joining board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ + testParameterBundles := *TestParameterBundles{}. + Append("Successfully join board", http.StatusSeeOther, nil, true, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil)). + Append("Failed joining board", http.StatusInternalServerError, + &common.APIError{ Err: errors.New("failed to join board"), StatusCode: http.StatusInternalServerError, StatusText: "no", ErrorText: "Could not join board", - }, - sessionExists: true, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyPublic, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, - }, - { - name: "Successfully joined board without session", - expectedCode: http.StatusCreated, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyPublic, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, - }, { - name: "Successfully joined board with passphrase", - expectedCode: http.StatusCreated, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyByPassphrase, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: &passphrase, - Salt: &salt, - }, - }, - { - name: "Successfully join board by invite with existing session request", - expectedCode: http.StatusSeeOther, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyByInvite, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: &passphrase, - Salt: &salt, - }, - sessionRequestExists: true, - }, - { - name: "Successfully join board by invite with existing session request", - expectedCode: http.StatusSeeOther, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyByInvite, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: &passphrase, - Salt: &salt, - }, - sessionRequestExists: false, - }, - } - - for _, tt := range tests { - suite.Run(tt.name, func() { + }, true, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil)). + Append("Successfully joined board without session", http.StatusCreated, nil, false, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil)). + Append("Successfully joined board with passphrase", http.StatusCreated, nil, false, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyByPassphrase, &passphrase, &salt)). + Append("Successfully join board by invite with existing session request", http.StatusSeeOther, nil, false, true, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyByInvite, &passphrase, &salt)). + Append("Successfully join board by invite with existing session request", http.StatusSeeOther, nil, false, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyByInvite, &passphrase, &salt)) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - sessionMock := new(SessionsMock) - s.boards = mock + boardMock := services.NewMockBoards(suite.T()) + sessionMock := services.NewMockBoardSessions(suite.T()) + s.boards = boardMock s.sessions = sessionMock + boardID := uuid.New() + userID := uuid.New() + + req := NewTestRequestBuilder("POST", fmt.Sprintf("/%s", boardID), strings.NewReader(`{"passphrase": "123"}`)). + AddToContext(identifiers.UserIdentifier, userID) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(te.sessionExists, nil) - boardID, _ := uuid.NewRandom() - userID, _ := uuid.NewRandom() - sessionMock.On("SessionExists", boardID, userID).Return(tt.sessionExists, nil) - if tt.sessionExists { - sessionMock.On("ParticipantBanned", boardID, userID).Return(false, tt.err) + if te.sessionExists { + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, te.err) } else { - //sessionMock.On("SessionExists", boardID, userID).Return(false, nil) - mock.On("Get", boardID).Return(tt.board, tt.err) + boardMock.EXPECT().Get(req.req.Context(), boardID).Return(te.board, te.err) } - if tt.board.AccessPolicy == types.AccessPolicyByInvite { - sessionMock.On("SessionRequestExists", boardID, userID).Return(tt.sessionRequestExists, tt.err) - if !tt.sessionRequestExists { - sessionMock.On("CreateSessionRequest", boardID, userID).Return(new(dto.BoardSessionRequest), tt.err) + if te.board.AccessPolicy == types.AccessPolicyByInvite { + sessionMock.EXPECT().SessionRequestExists(req.req.Context(), boardID, userID).Return(te.sessionRequestExists, te.err) + if !te.sessionRequestExists { + sessionMock.EXPECT().CreateSessionRequest(req.req.Context(), boardID, userID).Return(new(dto.BoardSessionRequest), te.err) } } else { - if !tt.sessionExists { - sessionMock.On("Create", boardID, userID).Return(new(dto.BoardSession), tt.err) + if !te.sessionExists { + sessionMock.EXPECT().Create(req.req.Context(), boardID, userID).Return(new(dto.BoardSession), te.err) } } - req := NewTestRequestBuilder("POST", fmt.Sprintf("/%s", boardID), strings.NewReader(`{"passphrase": "123"}`)). - AddToContext(identifiers.UserIdentifier, userID) - rctx := chi.NewRouteContext() - rctx.URLParams.Add("id", boardID.String()) - req.AddToContext(chi.RouteCtxKey, rctx) - rr := httptest.NewRecorder() s.joinBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) sessionMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestUpdateBoards() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully updated boards", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed updating board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to update board"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not update board", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully updated boards", http.StatusOK, nil, false, false, nil). + Append("Failed updating board", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to update board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update board", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() newName := "UpdatedName" newDescription := "UpdatedDescription" - boardID, _ := uuid.NewRandom() accessPolicy := types.AccessPolicyPublic boardReq := dto.BoardUpdateRequest{ Name: &newName, @@ -628,8 +330,6 @@ func (suite *BoardTestSuite) TestUpdateBoards() { ID: boardID, } - mock.On("Update", boardReq).Return(new(dto.Board), tt.err) - req := NewTestRequestBuilder("PUT", fmt.Sprintf("/%s", boardID), strings.NewReader(fmt.Sprintf(`{ "id": "%s", "name": "%s", @@ -638,152 +338,115 @@ func (suite *BoardTestSuite) TestUpdateBoards() { }`, boardID, newName, newDescription))). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().Update(req.req.Context(), boardReq).Return(new(dto.Board), te.err) + rr := httptest.NewRecorder() s.updateBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestSetTimer() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully set timer", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed set timer", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to set timer"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not set timer", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully set timer", http.StatusOK, nil, false, false, nil). + Append("Failed set timer", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to set timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not set timer", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() minutes := uint8(4) - mock.On("SetTimer", boardID, minutes).Return(new(dto.Board), tt.err) - req := NewTestRequestBuilder("PUT", "/timer", strings.NewReader(fmt.Sprintf(`{"minutes": %d}`, minutes))). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().SetTimer(req.req.Context(), boardID, minutes).Return(new(dto.Board), te.err) + rr := httptest.NewRecorder() s.setTimer(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestDeleteTimer() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully deleted timer", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed deleting timer", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to delete timer"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not delete timer", - }, - }, - } - for _, tt := range tests { + testParameterBundles := TestParameterBundles{}. + Append("Successfully deleted timer", http.StatusOK, nil, false, false, nil). + Append("Failed deleting timer", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to delete timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete timer", + }, false, false, nil) + + for _, tt := range *testParameterBundles { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() - - mock.On("DeleteTimer", boardID).Return(new(dto.Board), tt.err) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() req := NewTestRequestBuilder("DEL", "/timer", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().DeleteTimer(req.req.Context(), boardID).Return(new(dto.Board), tt.err) + rr := httptest.NewRecorder() s.deleteTimer(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestIncrementTimer() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully increment timer", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed incrementing timer", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to increment timer"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not increment timer", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully increment timer", http.StatusOK, nil, false, false, nil). + Append("Failed incrementing timer", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to increment timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not increment timer", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() - - mock.On("IncrementTimer", boardID).Return(new(dto.Board), tt.err) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() req := NewTestRequestBuilder("POST", "/timer/increment", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().IncrementTimer(req.req.Context(), boardID).Return(new(dto.Board), tt.err) + rr := httptest.NewRecorder() s.incrementTimer(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go index 27d972566e..cfac8cf8f0 100644 --- a/server/src/api/columns_test.go +++ b/server/src/api/columns_test.go @@ -1,11 +1,9 @@ package api import ( - "context" "errors" "fmt" "github.com/google/uuid" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" "net/http" "net/http/httptest" @@ -13,41 +11,11 @@ import ( "scrumlr.io/server/common/dto" "scrumlr.io/server/database/types" "scrumlr.io/server/identifiers" - "scrumlr.io/server/services" + "scrumlr.io/server/mocks/services" "strings" "testing" ) -type BoardMock struct { - services.Boards - mock.Mock -} - -func (m *BoardMock) CreateColumn(ctx context.Context, req dto.ColumnRequest) (*dto.Column, error) { - args := m.Called(req) - return args.Get(0).(*dto.Column), args.Error(1) -} - -func (m *BoardMock) DeleteColumn(ctx context.Context, board, column, user uuid.UUID) error { - args := m.Called(board, column, user) - return args.Error(0) -} - -func (m *BoardMock) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { - args := m.Called(body) - return args.Get(0).(*dto.Column), args.Error(1) -} - -func (m *BoardMock) GetColumn(ctx context.Context, boardID, columnID uuid.UUID) (*dto.Column, error) { - args := m.Called(boardID, columnID) - return args.Get(0).(*dto.Column), args.Error(1) -} - -func (m *BoardMock) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*dto.Column, error) { - args := m.Called(boardID) - return args.Get(0).([]*dto.Column), args.Error(1) -} - type ColumnTestSuite struct { suite.Suite } @@ -81,7 +49,7 @@ func (suite *ColumnTestSuite) TestCreateColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) name := "TestColumn" color := types.Color("backlog-blue") visible := true @@ -89,7 +57,13 @@ func (suite *ColumnTestSuite) TestCreateColumn() { boardID, _ := uuid.NewRandom() userID, _ := uuid.NewRandom() - mock.On("CreateColumn", dto.ColumnRequest{ + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( + `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, + ))).AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().CreateColumn(req.req.Context(), dto.ColumnRequest{ Name: name, Color: color, Visible: &visible, @@ -104,18 +78,12 @@ func (suite *ColumnTestSuite) TestCreateColumn() { Index: index, }, tt.err) - s.boards = mock - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( - `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, - ))).AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.UserIdentifier, userID) - rr := httptest.NewRecorder() + s.boards = boardMock s.createColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -145,25 +113,24 @@ func (suite *ColumnTestSuite) TestDeleteColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() userID, _ := uuid.NewRandom() - mock.On("DeleteColumn", boardID, columnID, userID).Return(tt.err) - - s.boards = mock - req := NewTestRequestBuilder("DEL", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID). AddToContext(identifiers.UserIdentifier, userID). AddToContext(identifiers.ColumnIdentifier, columnID) rr := httptest.NewRecorder() + boardMock.EXPECT().DeleteColumn(req.req.Context(), boardID, columnID, userID).Return(tt.err) + + s.boards = boardMock s.deleteColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -193,7 +160,7 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() @@ -202,7 +169,13 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { visible := false index := 0 - mock.On("UpdateColumn", dto.ColumnUpdateRequest{ + req := NewTestRequestBuilder("PUT", "/", strings.NewReader( + fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().UpdateColumn(req.req.Context(), dto.ColumnUpdateRequest{ Name: colName, Color: color, Visible: visible, @@ -217,18 +190,12 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { Index: index, }, tt.err) - s.boards = mock - - req := NewTestRequestBuilder("PUT", "/", strings.NewReader( - fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). - AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.ColumnIdentifier, columnID) - rr := httptest.NewRecorder() + s.boards = boardMock s.updateColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -258,7 +225,7 @@ func (suite *ColumnTestSuite) TestGetColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() @@ -275,19 +242,19 @@ func (suite *ColumnTestSuite) TestGetColumn() { Index: index, } - mock.On("GetColumn", boardID, columnID).Return(column, tt.err) - - s.boards = mock - req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID). AddToContext(identifiers.ColumnIdentifier, columnID) rr := httptest.NewRecorder() + boardMock.EXPECT().GetColumn(req.req.Context(), boardID, columnID).Return(column, tt.err) + + s.boards = boardMock + s.getColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -317,7 +284,7 @@ func (suite *ColumnTestSuite) TestGetColumns() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() @@ -334,18 +301,17 @@ func (suite *ColumnTestSuite) TestGetColumns() { Index: index, } - mock.On("ListColumns", boardID).Return([]*dto.Column{column}, tt.err) - - s.boards = mock - req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) rr := httptest.NewRecorder() + boardMock.EXPECT().ListColumns(req.req.Context(), boardID).Return([]*dto.Column{column}, tt.err) + + s.boards = boardMock s.getColumns(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } diff --git a/server/src/api/request_builder.go b/server/src/api/request_builder.go index d20f2c5be4..9772fbb5cd 100644 --- a/server/src/api/request_builder.go +++ b/server/src/api/request_builder.go @@ -27,5 +27,4 @@ func (b *TestRequestBuilder) AddToContext(key, val interface{}) *TestRequestBuil func (b *TestRequestBuilder) Request() *http.Request { return b.req.Clone(b.req.Context()) - } diff --git a/server/src/api/test_content_builder.go b/server/src/api/test_content_builder.go new file mode 100644 index 0000000000..913f2be7f3 --- /dev/null +++ b/server/src/api/test_content_builder.go @@ -0,0 +1,81 @@ +package api + +import "scrumlr.io/server/common/dto" + +type TestParameterBundle struct { + name string + expectedCode int + err error + sessionExists bool + sessionRequestExists bool + board *dto.Board +} + +type TestParameterBundleBuilder struct { + name string + expectedCode int + err error + sessionExists bool + sessionRequestExists bool + board *dto.Board +} + +type TestParameterBundles []TestParameterBundle + +func (testElements TestParameterBundles) Append(name string, expectedCode int, err error, sessionExists bool, sessionRequestExists bool, board *dto.Board) *TestParameterBundles { + t := append(testElements, + newTestParameterBundleBuilder(). + setName(name). + setExpectedCode(expectedCode). + setError(err). + setSessionExists(sessionExists). + setSessionRequestExists(sessionRequestExists). + setBoard(board). + build()) + return &t +} + +func newTestParameterBundleBuilder() *TestParameterBundleBuilder { + return &TestParameterBundleBuilder{} +} + +func (t *TestParameterBundleBuilder) setName(name string) *TestParameterBundleBuilder { + t.name = name + return t +} + +func (t *TestParameterBundleBuilder) setExpectedCode(code int) *TestParameterBundleBuilder { + t.expectedCode = code + return t +} + +func (t *TestParameterBundleBuilder) setError(err error) *TestParameterBundleBuilder { + t.err = err + return t +} + +func (t *TestParameterBundleBuilder) setSessionExists(sessionExists bool) *TestParameterBundleBuilder { + t.sessionExists = sessionExists + return t +} + +func (t *TestParameterBundleBuilder) setSessionRequestExists(sessionRequestExists bool) *TestParameterBundleBuilder { + t.sessionRequestExists = sessionRequestExists + return t +} + +func (t *TestParameterBundleBuilder) setBoard(board *dto.Board) *TestParameterBundleBuilder { + t.board = board + return t +} + +func (t *TestParameterBundleBuilder) build() TestParameterBundle { + return TestParameterBundle{ + name: t.name, + expectedCode: t.expectedCode, + err: t.err, + sessionRequestExists: t.sessionRequestExists, + sessionExists: t.sessionExists, + board: t.board, + } +} From 30c29c39a3978c853fa2b49a4197c2f780085daf Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 16:00:14 +0100 Subject: [PATCH 06/27] feat: commit mockery generated interface implementations --- .../src/mocks/services/mock_BoardReactions.go | 74 ++ .../src/mocks/services/mock_BoardSessions.go | 906 ++++++++++++++++++ .../src/mocks/services/mock_BoardTemplates.go | 608 ++++++++++++ server/src/mocks/services/mock_Boards.go | 905 +++++++++++++++++ server/src/mocks/services/mock_Feedback.go | 130 +++ server/src/mocks/services/mock_Health.go | 122 +++ server/src/mocks/services/mock_Notes.go | 382 ++++++++ server/src/mocks/services/mock_Reactions.go | 328 +++++++ server/src/mocks/services/mock_Users.go | 582 +++++++++++ server/src/mocks/services/mock_Votings.go | 443 +++++++++ 10 files changed, 4480 insertions(+) create mode 100644 server/src/mocks/services/mock_BoardReactions.go create mode 100644 server/src/mocks/services/mock_BoardSessions.go create mode 100644 server/src/mocks/services/mock_BoardTemplates.go create mode 100644 server/src/mocks/services/mock_Boards.go create mode 100644 server/src/mocks/services/mock_Feedback.go create mode 100644 server/src/mocks/services/mock_Health.go create mode 100644 server/src/mocks/services/mock_Notes.go create mode 100644 server/src/mocks/services/mock_Reactions.go create mode 100644 server/src/mocks/services/mock_Users.go create mode 100644 server/src/mocks/services/mock_Votings.go diff --git a/server/src/mocks/services/mock_BoardReactions.go b/server/src/mocks/services/mock_BoardReactions.go new file mode 100644 index 0000000000..0eee513361 --- /dev/null +++ b/server/src/mocks/services/mock_BoardReactions.go @@ -0,0 +1,74 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockBoardReactions is an autogenerated mock type for the BoardReactions type +type MockBoardReactions struct { + mock.Mock +} + +type MockBoardReactions_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoardReactions) EXPECT() *MockBoardReactions_Expecter { + return &MockBoardReactions_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, board, body +func (_m *MockBoardReactions) Create(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest) { + _m.Called(ctx, board, body) +} + +// MockBoardReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoardReactions_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - body dto.BoardReactionCreateRequest +func (_e *MockBoardReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockBoardReactions_Create_Call { + return &MockBoardReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} +} + +func (_c *MockBoardReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.BoardReactionCreateRequest)) + }) + return _c +} + +func (_c *MockBoardReactions_Create_Call) Return() *MockBoardReactions_Create_Call { + _c.Call.Return() + return _c +} + +func (_c *MockBoardReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { + _c.Run(run) + return _c +} + +// NewMockBoardReactions creates a new instance of MockBoardReactions. 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 NewMockBoardReactions(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoardReactions { + mock := &MockBoardReactions{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_BoardSessions.go b/server/src/mocks/services/mock_BoardSessions.go new file mode 100644 index 0000000000..bc2cac6dfd --- /dev/null +++ b/server/src/mocks/services/mock_BoardSessions.go @@ -0,0 +1,906 @@ +// 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" +) + +// MockBoardSessions is an autogenerated mock type for the BoardSessions type +type MockBoardSessions struct { + mock.Mock +} + +type MockBoardSessions_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoardSessions) EXPECT() *MockBoardSessions_Expecter { + return &MockBoardSessions_Expecter{mock: &_m.Mock} +} + +// Connect provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Connect(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) error { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Connect") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardSessions_Connect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Connect' +type MockBoardSessions_Connect_Call struct { + *mock.Call +} + +// Connect is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Connect(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Connect_Call { + return &MockBoardSessions_Connect_Call{Call: _e.mock.On("Connect", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Connect_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_Connect_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 *MockBoardSessions_Connect_Call) Return(_a0 error) *MockBoardSessions_Connect_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardSessions_Connect_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) error) *MockBoardSessions_Connect_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Create(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSession, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSession); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoardSessions_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Create(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Create_Call { + return &MockBoardSessions_Create_Call{Call: _e.mock.On("Create", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Create_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_Create_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 *MockBoardSessions_Create_Call) Return(_a0 *dto.BoardSession, _a1 error) *MockBoardSessions_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)) *MockBoardSessions_Create_Call { + _c.Call.Return(run) + return _c +} + +// CreateSessionRequest provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) CreateSessionRequest(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for CreateSessionRequest") + } + + var r0 *dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSessionRequest); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_CreateSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSessionRequest' +type MockBoardSessions_CreateSessionRequest_Call struct { + *mock.Call +} + +// CreateSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) CreateSessionRequest(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_CreateSessionRequest_Call { + return &MockBoardSessions_CreateSessionRequest_Call{Call: _e.mock.On("CreateSessionRequest", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_CreateSessionRequest_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_CreateSessionRequest_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 *MockBoardSessions_CreateSessionRequest_Call) Return(_a0 *dto.BoardSessionRequest, _a1 error) *MockBoardSessions_CreateSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_CreateSessionRequest_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)) *MockBoardSessions_CreateSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// Disconnect provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Disconnect(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) error { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Disconnect") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardSessions_Disconnect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Disconnect' +type MockBoardSessions_Disconnect_Call struct { + *mock.Call +} + +// Disconnect is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Disconnect(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Disconnect_Call { + return &MockBoardSessions_Disconnect_Call{Call: _e.mock.On("Disconnect", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Disconnect_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_Disconnect_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 *MockBoardSessions_Disconnect_Call) Return(_a0 error) *MockBoardSessions_Disconnect_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardSessions_Disconnect_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) error) *MockBoardSessions_Disconnect_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Get(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSession, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSession); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockBoardSessions_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Get(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Get_Call { + return &MockBoardSessions_Get_Call{Call: _e.mock.On("Get", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Get_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_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 *MockBoardSessions_Get_Call) Return(_a0 *dto.BoardSession, _a1 error) *MockBoardSessions_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)) *MockBoardSessions_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetSessionRequest provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) GetSessionRequest(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for GetSessionRequest") + } + + var r0 *dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSessionRequest); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_GetSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSessionRequest' +type MockBoardSessions_GetSessionRequest_Call struct { + *mock.Call +} + +// GetSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) GetSessionRequest(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_GetSessionRequest_Call { + return &MockBoardSessions_GetSessionRequest_Call{Call: _e.mock.On("GetSessionRequest", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_GetSessionRequest_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_GetSessionRequest_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 *MockBoardSessions_GetSessionRequest_Call) Return(_a0 *dto.BoardSessionRequest, _a1 error) *MockBoardSessions_GetSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_GetSessionRequest_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)) *MockBoardSessions_GetSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, boardID, f +func (_m *MockBoardSessions) List(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter) ([]*dto.BoardSession, error) { + ret := _m.Called(ctx, boardID, f) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, filter.BoardSessionFilter) ([]*dto.BoardSession, error)); ok { + return rf(ctx, boardID, f) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, filter.BoardSessionFilter) []*dto.BoardSession); ok { + r0 = rf(ctx, boardID, f) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, filter.BoardSessionFilter) error); ok { + r1 = rf(ctx, boardID, f) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockBoardSessions_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - f filter.BoardSessionFilter +func (_e *MockBoardSessions_Expecter) List(ctx interface{}, boardID interface{}, f interface{}) *MockBoardSessions_List_Call { + return &MockBoardSessions_List_Call{Call: _e.mock.On("List", ctx, boardID, f)} +} + +func (_c *MockBoardSessions_List_Call) Run(run func(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter)) *MockBoardSessions_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(filter.BoardSessionFilter)) + }) + return _c +} + +func (_c *MockBoardSessions_List_Call) Return(_a0 []*dto.BoardSession, _a1 error) *MockBoardSessions_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_List_Call) RunAndReturn(run func(context.Context, uuid.UUID, filter.BoardSessionFilter) ([]*dto.BoardSession, error)) *MockBoardSessions_List_Call { + _c.Call.Return(run) + return _c +} + +// ListSessionRequest provides a mock function with given fields: ctx, boardID, statusQuery +func (_m *MockBoardSessions) ListSessionRequest(ctx context.Context, boardID uuid.UUID, statusQuery string) ([]*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, boardID, statusQuery) + + if len(ret) == 0 { + panic("no return value specified for ListSessionRequest") + } + + var r0 []*dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string) ([]*dto.BoardSessionRequest, error)); ok { + return rf(ctx, boardID, statusQuery) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string) []*dto.BoardSessionRequest); ok { + r0 = rf(ctx, boardID, statusQuery) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string) error); ok { + r1 = rf(ctx, boardID, statusQuery) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_ListSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSessionRequest' +type MockBoardSessions_ListSessionRequest_Call struct { + *mock.Call +} + +// ListSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - statusQuery string +func (_e *MockBoardSessions_Expecter) ListSessionRequest(ctx interface{}, boardID interface{}, statusQuery interface{}) *MockBoardSessions_ListSessionRequest_Call { + return &MockBoardSessions_ListSessionRequest_Call{Call: _e.mock.On("ListSessionRequest", ctx, boardID, statusQuery)} +} + +func (_c *MockBoardSessions_ListSessionRequest_Call) Run(run func(ctx context.Context, boardID uuid.UUID, statusQuery string)) *MockBoardSessions_ListSessionRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string)) + }) + return _c +} + +func (_c *MockBoardSessions_ListSessionRequest_Call) Return(_a0 []*dto.BoardSessionRequest, _a1 error) *MockBoardSessions_ListSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_ListSessionRequest_Call) RunAndReturn(run func(context.Context, uuid.UUID, string) ([]*dto.BoardSessionRequest, error)) *MockBoardSessions_ListSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// ModeratorSessionExists provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) ModeratorSessionExists(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for ModeratorSessionExists") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_ModeratorSessionExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ModeratorSessionExists' +type MockBoardSessions_ModeratorSessionExists_Call struct { + *mock.Call +} + +// ModeratorSessionExists is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) ModeratorSessionExists(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_ModeratorSessionExists_Call { + return &MockBoardSessions_ModeratorSessionExists_Call{Call: _e.mock.On("ModeratorSessionExists", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_ModeratorSessionExists_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_ModeratorSessionExists_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 *MockBoardSessions_ModeratorSessionExists_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_ModeratorSessionExists_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_ModeratorSessionExists_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_ModeratorSessionExists_Call { + _c.Call.Return(run) + return _c +} + +// ParticipantBanned provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) ParticipantBanned(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for ParticipantBanned") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_ParticipantBanned_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ParticipantBanned' +type MockBoardSessions_ParticipantBanned_Call struct { + *mock.Call +} + +// ParticipantBanned is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) ParticipantBanned(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_ParticipantBanned_Call { + return &MockBoardSessions_ParticipantBanned_Call{Call: _e.mock.On("ParticipantBanned", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_ParticipantBanned_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_ParticipantBanned_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 *MockBoardSessions_ParticipantBanned_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_ParticipantBanned_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_ParticipantBanned_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_ParticipantBanned_Call { + _c.Call.Return(run) + return _c +} + +// SessionExists provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) SessionExists(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for SessionExists") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_SessionExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SessionExists' +type MockBoardSessions_SessionExists_Call struct { + *mock.Call +} + +// SessionExists is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) SessionExists(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_SessionExists_Call { + return &MockBoardSessions_SessionExists_Call{Call: _e.mock.On("SessionExists", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_SessionExists_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_SessionExists_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 *MockBoardSessions_SessionExists_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_SessionExists_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_SessionExists_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_SessionExists_Call { + _c.Call.Return(run) + return _c +} + +// SessionRequestExists provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) SessionRequestExists(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for SessionRequestExists") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_SessionRequestExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SessionRequestExists' +type MockBoardSessions_SessionRequestExists_Call struct { + *mock.Call +} + +// SessionRequestExists is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) SessionRequestExists(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_SessionRequestExists_Call { + return &MockBoardSessions_SessionRequestExists_Call{Call: _e.mock.On("SessionRequestExists", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_SessionRequestExists_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_SessionRequestExists_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 *MockBoardSessions_SessionRequestExists_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_SessionRequestExists_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_SessionRequestExists_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_SessionRequestExists_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockBoardSessions) Update(ctx context.Context, body dto.BoardSessionUpdateRequest) (*dto.BoardSession, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionUpdateRequest) (*dto.BoardSession, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionUpdateRequest) *dto.BoardSession); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardSessionUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockBoardSessions_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardSessionUpdateRequest +func (_e *MockBoardSessions_Expecter) Update(ctx interface{}, body interface{}) *MockBoardSessions_Update_Call { + return &MockBoardSessions_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockBoardSessions_Update_Call) Run(run func(ctx context.Context, body dto.BoardSessionUpdateRequest)) *MockBoardSessions_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardSessionUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardSessions_Update_Call) Return(_a0 *dto.BoardSession, _a1 error) *MockBoardSessions_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_Update_Call) RunAndReturn(run func(context.Context, dto.BoardSessionUpdateRequest) (*dto.BoardSession, error)) *MockBoardSessions_Update_Call { + _c.Call.Return(run) + return _c +} + +// UpdateAll provides a mock function with given fields: ctx, body +func (_m *MockBoardSessions) UpdateAll(ctx context.Context, body dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateAll") + } + + var r0 []*dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionsUpdateRequest) []*dto.BoardSession); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardSessionsUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_UpdateAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateAll' +type MockBoardSessions_UpdateAll_Call struct { + *mock.Call +} + +// UpdateAll is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardSessionsUpdateRequest +func (_e *MockBoardSessions_Expecter) UpdateAll(ctx interface{}, body interface{}) *MockBoardSessions_UpdateAll_Call { + return &MockBoardSessions_UpdateAll_Call{Call: _e.mock.On("UpdateAll", ctx, body)} +} + +func (_c *MockBoardSessions_UpdateAll_Call) Run(run func(ctx context.Context, body dto.BoardSessionsUpdateRequest)) *MockBoardSessions_UpdateAll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardSessionsUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardSessions_UpdateAll_Call) Return(_a0 []*dto.BoardSession, _a1 error) *MockBoardSessions_UpdateAll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_UpdateAll_Call) RunAndReturn(run func(context.Context, dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error)) *MockBoardSessions_UpdateAll_Call { + _c.Call.Return(run) + return _c +} + +// UpdateSessionRequest provides a mock function with given fields: ctx, body +func (_m *MockBoardSessions) UpdateSessionRequest(ctx context.Context, body dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateSessionRequest") + } + + var r0 *dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionRequestUpdate) *dto.BoardSessionRequest); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardSessionRequestUpdate) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_UpdateSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateSessionRequest' +type MockBoardSessions_UpdateSessionRequest_Call struct { + *mock.Call +} + +// UpdateSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardSessionRequestUpdate +func (_e *MockBoardSessions_Expecter) UpdateSessionRequest(ctx interface{}, body interface{}) *MockBoardSessions_UpdateSessionRequest_Call { + return &MockBoardSessions_UpdateSessionRequest_Call{Call: _e.mock.On("UpdateSessionRequest", ctx, body)} +} + +func (_c *MockBoardSessions_UpdateSessionRequest_Call) Run(run func(ctx context.Context, body dto.BoardSessionRequestUpdate)) *MockBoardSessions_UpdateSessionRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardSessionRequestUpdate)) + }) + return _c +} + +func (_c *MockBoardSessions_UpdateSessionRequest_Call) Return(_a0 *dto.BoardSessionRequest, _a1 error) *MockBoardSessions_UpdateSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_UpdateSessionRequest_Call) RunAndReturn(run func(context.Context, dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error)) *MockBoardSessions_UpdateSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// NewMockBoardSessions creates a new instance of MockBoardSessions. 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 NewMockBoardSessions(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoardSessions { + mock := &MockBoardSessions{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_BoardTemplates.go b/server/src/mocks/services/mock_BoardTemplates.go new file mode 100644 index 0000000000..5511784877 --- /dev/null +++ b/server/src/mocks/services/mock_BoardTemplates.go @@ -0,0 +1,608 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockBoardTemplates is an autogenerated mock type for the BoardTemplates type +type MockBoardTemplates struct { + mock.Mock +} + +type MockBoardTemplates_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoardTemplates) EXPECT() *MockBoardTemplates_Expecter { + return &MockBoardTemplates_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) Create(ctx context.Context, body dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.BoardTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) *dto.BoardTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.CreateBoardTemplateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoardTemplates_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.CreateBoardTemplateRequest +func (_e *MockBoardTemplates_Expecter) Create(ctx interface{}, body interface{}) *MockBoardTemplates_Create_Call { + return &MockBoardTemplates_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockBoardTemplates_Create_Call) Run(run func(ctx context.Context, body dto.CreateBoardTemplateRequest)) *MockBoardTemplates_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.CreateBoardTemplateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_Create_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_Create_Call) RunAndReturn(run func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Create_Call { + _c.Call.Return(run) + return _c +} + +// CreateColumnTemplate provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) CreateColumnTemplate(ctx context.Context, body dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for CreateColumnTemplate") + } + + var r0 *dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) *dto.ColumnTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.ColumnTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_CreateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateColumnTemplate' +type MockBoardTemplates_CreateColumnTemplate_Call struct { + *mock.Call +} + +// CreateColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnTemplateRequest +func (_e *MockBoardTemplates_Expecter) CreateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_CreateColumnTemplate_Call { + return &MockBoardTemplates_CreateColumnTemplate_Call{Call: _e.mock.On("CreateColumnTemplate", ctx, body)} +} + +func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateRequest)) *MockBoardTemplates_CreateColumnTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnTemplateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_CreateColumnTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_CreateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_CreateColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, id +func (_m *MockBoardTemplates) Delete(ctx context.Context, id uuid.UUID) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardTemplates_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockBoardTemplates_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoardTemplates_Expecter) Delete(ctx interface{}, id interface{}) *MockBoardTemplates_Delete_Call { + return &MockBoardTemplates_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} +} + +func (_c *MockBoardTemplates_Delete_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_Delete_Call) Return(_a0 error) *MockBoardTemplates_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardTemplates_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID) error) *MockBoardTemplates_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteColumnTemplate provides a mock function with given fields: ctx, boar, column, user +func (_m *MockBoardTemplates) DeleteColumnTemplate(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID) error { + ret := _m.Called(ctx, boar, column, user) + + if len(ret) == 0 { + panic("no return value specified for DeleteColumnTemplate") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, boar, column, user) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardTemplates_DeleteColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteColumnTemplate' +type MockBoardTemplates_DeleteColumnTemplate_Call struct { + *mock.Call +} + +// DeleteColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - boar uuid.UUID +// - column uuid.UUID +// - user uuid.UUID +func (_e *MockBoardTemplates_Expecter) DeleteColumnTemplate(ctx interface{}, boar interface{}, column interface{}, user interface{}) *MockBoardTemplates_DeleteColumnTemplate_Call { + return &MockBoardTemplates_DeleteColumnTemplate_Call{Call: _e.mock.On("DeleteColumnTemplate", ctx, boar, column, user)} +} + +func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Run(run func(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID)) *MockBoardTemplates_DeleteColumnTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Return(_a0 error) *MockBoardTemplates_DeleteColumnTemplate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockBoardTemplates_DeleteColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockBoardTemplates) Get(ctx context.Context, id uuid.UUID) (*dto.BoardTemplate, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.BoardTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.BoardTemplate); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockBoardTemplates_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoardTemplates_Expecter) Get(ctx interface{}, id interface{}) *MockBoardTemplates_Get_Call { + return &MockBoardTemplates_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockBoardTemplates_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_Get_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)) *MockBoardTemplates_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetColumnTemplate provides a mock function with given fields: ctx, boardID, columnID +func (_m *MockBoardTemplates) GetColumnTemplate(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, boardID, columnID) + + if len(ret) == 0 { + panic("no return value specified for GetColumnTemplate") + } + + var r0 *dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)); ok { + return rf(ctx, boardID, columnID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.ColumnTemplate); ok { + r0 = rf(ctx, boardID, columnID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.ColumnTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, columnID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_GetColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetColumnTemplate' +type MockBoardTemplates_GetColumnTemplate_Call struct { + *mock.Call +} + +// GetColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - columnID uuid.UUID +func (_e *MockBoardTemplates_Expecter) GetColumnTemplate(ctx interface{}, boardID interface{}, columnID interface{}) *MockBoardTemplates_GetColumnTemplate_Call { + return &MockBoardTemplates_GetColumnTemplate_Call{Call: _e.mock.On("GetColumnTemplate", ctx, boardID, columnID)} +} + +func (_c *MockBoardTemplates_GetColumnTemplate_Call) Run(run func(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID)) *MockBoardTemplates_GetColumnTemplate_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 *MockBoardTemplates_GetColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_GetColumnTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_GetColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)) *MockBoardTemplates_GetColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, user +func (_m *MockBoardTemplates) List(ctx context.Context, user uuid.UUID) ([]*dto.BoardTemplateFull, error) { + ret := _m.Called(ctx, user) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.BoardTemplateFull + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)); ok { + return rf(ctx, user) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.BoardTemplateFull); ok { + r0 = rf(ctx, user) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardTemplateFull) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, user) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockBoardTemplates_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - user uuid.UUID +func (_e *MockBoardTemplates_Expecter) List(ctx interface{}, user interface{}) *MockBoardTemplates_List_Call { + return &MockBoardTemplates_List_Call{Call: _e.mock.On("List", ctx, user)} +} + +func (_c *MockBoardTemplates_List_Call) Run(run func(ctx context.Context, user uuid.UUID)) *MockBoardTemplates_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_List_Call) Return(_a0 []*dto.BoardTemplateFull, _a1 error) *MockBoardTemplates_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)) *MockBoardTemplates_List_Call { + _c.Call.Return(run) + return _c +} + +// ListColumnTemplates provides a mock function with given fields: ctx, board +func (_m *MockBoardTemplates) ListColumnTemplates(ctx context.Context, board uuid.UUID) ([]*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, board) + + if len(ret) == 0 { + panic("no return value specified for ListColumnTemplates") + } + + var r0 []*dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)); ok { + return rf(ctx, board) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.ColumnTemplate); ok { + r0 = rf(ctx, board) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.ColumnTemplate) + } + } + + 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 +} + +// MockBoardTemplates_ListColumnTemplates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListColumnTemplates' +type MockBoardTemplates_ListColumnTemplates_Call struct { + *mock.Call +} + +// ListColumnTemplates is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +func (_e *MockBoardTemplates_Expecter) ListColumnTemplates(ctx interface{}, board interface{}) *MockBoardTemplates_ListColumnTemplates_Call { + return &MockBoardTemplates_ListColumnTemplates_Call{Call: _e.mock.On("ListColumnTemplates", ctx, board)} +} + +func (_c *MockBoardTemplates_ListColumnTemplates_Call) Run(run func(ctx context.Context, board uuid.UUID)) *MockBoardTemplates_ListColumnTemplates_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_ListColumnTemplates_Call) Return(_a0 []*dto.ColumnTemplate, _a1 error) *MockBoardTemplates_ListColumnTemplates_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_ListColumnTemplates_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)) *MockBoardTemplates_ListColumnTemplates_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) Update(ctx context.Context, body dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.BoardTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) *dto.BoardTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardTemplateUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockBoardTemplates_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardTemplateUpdateRequest +func (_e *MockBoardTemplates_Expecter) Update(ctx interface{}, body interface{}) *MockBoardTemplates_Update_Call { + return &MockBoardTemplates_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockBoardTemplates_Update_Call) Run(run func(ctx context.Context, body dto.BoardTemplateUpdateRequest)) *MockBoardTemplates_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardTemplateUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_Update_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_Update_Call) RunAndReturn(run func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Update_Call { + _c.Call.Return(run) + return _c +} + +// UpdateColumnTemplate provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) UpdateColumnTemplate(ctx context.Context, body dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateColumnTemplate") + } + + var r0 *dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) *dto.ColumnTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.ColumnTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_UpdateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateColumnTemplate' +type MockBoardTemplates_UpdateColumnTemplate_Call struct { + *mock.Call +} + +// UpdateColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnTemplateUpdateRequest +func (_e *MockBoardTemplates_Expecter) UpdateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_UpdateColumnTemplate_Call { + return &MockBoardTemplates_UpdateColumnTemplate_Call{Call: _e.mock.On("UpdateColumnTemplate", ctx, body)} +} + +func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateUpdateRequest)) *MockBoardTemplates_UpdateColumnTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnTemplateUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_UpdateColumnTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_UpdateColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// NewMockBoardTemplates creates a new instance of MockBoardTemplates. 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 NewMockBoardTemplates(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoardTemplates { + mock := &MockBoardTemplates{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Boards.go b/server/src/mocks/services/mock_Boards.go new file mode 100644 index 0000000000..34ade264b0 --- /dev/null +++ b/server/src/mocks/services/mock_Boards.go @@ -0,0 +1,905 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockBoards is an autogenerated mock type for the Boards type +type MockBoards struct { + mock.Mock +} + +type MockBoards_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoards) EXPECT() *MockBoards_Expecter { + return &MockBoards_Expecter{mock: &_m.Mock} +} + +// BoardOverview provides a mock function with given fields: ctx, boardIDs, user +func (_m *MockBoards) BoardOverview(ctx context.Context, boardIDs []uuid.UUID, user uuid.UUID) ([]*dto.BoardOverview, error) { + ret := _m.Called(ctx, boardIDs, user) + + if len(ret) == 0 { + panic("no return value specified for BoardOverview") + } + + var r0 []*dto.BoardOverview + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []uuid.UUID, uuid.UUID) ([]*dto.BoardOverview, error)); ok { + return rf(ctx, boardIDs, user) + } + if rf, ok := ret.Get(0).(func(context.Context, []uuid.UUID, uuid.UUID) []*dto.BoardOverview); ok { + r0 = rf(ctx, boardIDs, user) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardOverview) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardIDs, user) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_BoardOverview_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BoardOverview' +type MockBoards_BoardOverview_Call struct { + *mock.Call +} + +// BoardOverview is a helper method to define mock.On call +// - ctx context.Context +// - boardIDs []uuid.UUID +// - user uuid.UUID +func (_e *MockBoards_Expecter) BoardOverview(ctx interface{}, boardIDs interface{}, user interface{}) *MockBoards_BoardOverview_Call { + return &MockBoards_BoardOverview_Call{Call: _e.mock.On("BoardOverview", ctx, boardIDs, user)} +} + +func (_c *MockBoards_BoardOverview_Call) Run(run func(ctx context.Context, boardIDs []uuid.UUID, user uuid.UUID)) *MockBoards_BoardOverview_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 *MockBoards_BoardOverview_Call) Return(_a0 []*dto.BoardOverview, _a1 error) *MockBoards_BoardOverview_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_BoardOverview_Call) RunAndReturn(run func(context.Context, []uuid.UUID, uuid.UUID) ([]*dto.BoardOverview, error)) *MockBoards_BoardOverview_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockBoards) Create(ctx context.Context, body dto.CreateBoardRequest) (*dto.Board, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardRequest) (*dto.Board, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardRequest) *dto.Board); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.CreateBoardRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoards_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.CreateBoardRequest +func (_e *MockBoards_Expecter) Create(ctx interface{}, body interface{}) *MockBoards_Create_Call { + return &MockBoards_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockBoards_Create_Call) Run(run func(ctx context.Context, body dto.CreateBoardRequest)) *MockBoards_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.CreateBoardRequest)) + }) + return _c +} + +func (_c *MockBoards_Create_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_Create_Call) RunAndReturn(run func(context.Context, dto.CreateBoardRequest) (*dto.Board, error)) *MockBoards_Create_Call { + _c.Call.Return(run) + return _c +} + +// CreateColumn provides a mock function with given fields: ctx, body +func (_m *MockBoards) CreateColumn(ctx context.Context, body dto.ColumnRequest) (*dto.Column, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for CreateColumn") + } + + var r0 *dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) (*dto.Column, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) *dto.Column); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_CreateColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateColumn' +type MockBoards_CreateColumn_Call struct { + *mock.Call +} + +// CreateColumn is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnRequest +func (_e *MockBoards_Expecter) CreateColumn(ctx interface{}, body interface{}) *MockBoards_CreateColumn_Call { + return &MockBoards_CreateColumn_Call{Call: _e.mock.On("CreateColumn", ctx, body)} +} + +func (_c *MockBoards_CreateColumn_Call) Run(run func(ctx context.Context, body dto.ColumnRequest)) *MockBoards_CreateColumn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnRequest)) + }) + return _c +} + +func (_c *MockBoards_CreateColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_CreateColumn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_CreateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnRequest) (*dto.Column, error)) *MockBoards_CreateColumn_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, id +func (_m *MockBoards) Delete(ctx context.Context, id uuid.UUID) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoards_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockBoards_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) Delete(ctx interface{}, id interface{}) *MockBoards_Delete_Call { + return &MockBoards_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} +} + +func (_c *MockBoards_Delete_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_Delete_Call) Return(_a0 error) *MockBoards_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoards_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID) error) *MockBoards_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteColumn provides a mock function with given fields: ctx, board, column, user +func (_m *MockBoards) DeleteColumn(ctx context.Context, board uuid.UUID, column uuid.UUID, user uuid.UUID) error { + ret := _m.Called(ctx, board, column, user) + + if len(ret) == 0 { + panic("no return value specified for DeleteColumn") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, board, column, user) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoards_DeleteColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteColumn' +type MockBoards_DeleteColumn_Call struct { + *mock.Call +} + +// DeleteColumn is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - column uuid.UUID +// - user uuid.UUID +func (_e *MockBoards_Expecter) DeleteColumn(ctx interface{}, board interface{}, column interface{}, user interface{}) *MockBoards_DeleteColumn_Call { + return &MockBoards_DeleteColumn_Call{Call: _e.mock.On("DeleteColumn", ctx, board, column, user)} +} + +func (_c *MockBoards_DeleteColumn_Call) Run(run func(ctx context.Context, board uuid.UUID, column uuid.UUID, user uuid.UUID)) *MockBoards_DeleteColumn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_DeleteColumn_Call) Return(_a0 error) *MockBoards_DeleteColumn_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoards_DeleteColumn_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockBoards_DeleteColumn_Call { + _c.Call.Return(run) + return _c +} + +// DeleteTimer provides a mock function with given fields: ctx, id +func (_m *MockBoards) DeleteTimer(ctx context.Context, id uuid.UUID) (*dto.Board, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for DeleteTimer") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Board, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Board); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_DeleteTimer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteTimer' +type MockBoards_DeleteTimer_Call struct { + *mock.Call +} + +// DeleteTimer is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) DeleteTimer(ctx interface{}, id interface{}) *MockBoards_DeleteTimer_Call { + return &MockBoards_DeleteTimer_Call{Call: _e.mock.On("DeleteTimer", ctx, id)} +} + +func (_c *MockBoards_DeleteTimer_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_DeleteTimer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_DeleteTimer_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_DeleteTimer_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_DeleteTimer_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Board, error)) *MockBoards_DeleteTimer_Call { + _c.Call.Return(run) + return _c +} + +// FullBoard provides a mock function with given fields: ctx, boardID +func (_m *MockBoards) FullBoard(ctx context.Context, boardID uuid.UUID) (*dto.FullBoard, error) { + ret := _m.Called(ctx, boardID) + + if len(ret) == 0 { + panic("no return value specified for FullBoard") + } + + var r0 *dto.FullBoard + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.FullBoard, error)); ok { + return rf(ctx, boardID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.FullBoard); ok { + r0 = rf(ctx, boardID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.FullBoard) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, boardID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_FullBoard_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FullBoard' +type MockBoards_FullBoard_Call struct { + *mock.Call +} + +// FullBoard is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +func (_e *MockBoards_Expecter) FullBoard(ctx interface{}, boardID interface{}) *MockBoards_FullBoard_Call { + return &MockBoards_FullBoard_Call{Call: _e.mock.On("FullBoard", ctx, boardID)} +} + +func (_c *MockBoards_FullBoard_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockBoards_FullBoard_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_FullBoard_Call) Return(_a0 *dto.FullBoard, _a1 error) *MockBoards_FullBoard_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_FullBoard_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.FullBoard, error)) *MockBoards_FullBoard_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockBoards) Get(ctx context.Context, id uuid.UUID) (*dto.Board, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Board, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Board); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockBoards_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) Get(ctx interface{}, id interface{}) *MockBoards_Get_Call { + return &MockBoards_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockBoards_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_Get_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Board, error)) *MockBoards_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetBoards provides a mock function with given fields: ctx, userID +func (_m *MockBoards) GetBoards(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) { + ret := _m.Called(ctx, userID) + + if len(ret) == 0 { + panic("no return value specified for GetBoards") + } + + var r0 []uuid.UUID + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]uuid.UUID, error)); ok { + return rf(ctx, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []uuid.UUID); ok { + r0 = rf(ctx, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uuid.UUID) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_GetBoards_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBoards' +type MockBoards_GetBoards_Call struct { + *mock.Call +} + +// GetBoards is a helper method to define mock.On call +// - ctx context.Context +// - userID uuid.UUID +func (_e *MockBoards_Expecter) GetBoards(ctx interface{}, userID interface{}) *MockBoards_GetBoards_Call { + return &MockBoards_GetBoards_Call{Call: _e.mock.On("GetBoards", ctx, userID)} +} + +func (_c *MockBoards_GetBoards_Call) Run(run func(ctx context.Context, userID uuid.UUID)) *MockBoards_GetBoards_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_GetBoards_Call) Return(_a0 []uuid.UUID, _a1 error) *MockBoards_GetBoards_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_GetBoards_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]uuid.UUID, error)) *MockBoards_GetBoards_Call { + _c.Call.Return(run) + return _c +} + +// GetColumn provides a mock function with given fields: ctx, boardID, columnID +func (_m *MockBoards) GetColumn(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*dto.Column, error) { + ret := _m.Called(ctx, boardID, columnID) + + if len(ret) == 0 { + panic("no return value specified for GetColumn") + } + + var r0 *dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.Column, error)); ok { + return rf(ctx, boardID, columnID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.Column); ok { + r0 = rf(ctx, boardID, columnID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, columnID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_GetColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetColumn' +type MockBoards_GetColumn_Call struct { + *mock.Call +} + +// GetColumn is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - columnID uuid.UUID +func (_e *MockBoards_Expecter) GetColumn(ctx interface{}, boardID interface{}, columnID interface{}) *MockBoards_GetColumn_Call { + return &MockBoards_GetColumn_Call{Call: _e.mock.On("GetColumn", ctx, boardID, columnID)} +} + +func (_c *MockBoards_GetColumn_Call) Run(run func(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID)) *MockBoards_GetColumn_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 *MockBoards_GetColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_GetColumn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_GetColumn_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.Column, error)) *MockBoards_GetColumn_Call { + _c.Call.Return(run) + return _c +} + +// IncrementTimer provides a mock function with given fields: ctx, id +func (_m *MockBoards) IncrementTimer(ctx context.Context, id uuid.UUID) (*dto.Board, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for IncrementTimer") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Board, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Board); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_IncrementTimer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IncrementTimer' +type MockBoards_IncrementTimer_Call struct { + *mock.Call +} + +// IncrementTimer is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) IncrementTimer(ctx interface{}, id interface{}) *MockBoards_IncrementTimer_Call { + return &MockBoards_IncrementTimer_Call{Call: _e.mock.On("IncrementTimer", ctx, id)} +} + +func (_c *MockBoards_IncrementTimer_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_IncrementTimer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_IncrementTimer_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_IncrementTimer_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_IncrementTimer_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Board, error)) *MockBoards_IncrementTimer_Call { + _c.Call.Return(run) + return _c +} + +// ListColumns provides a mock function with given fields: ctx, boardID +func (_m *MockBoards) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*dto.Column, error) { + ret := _m.Called(ctx, boardID) + + if len(ret) == 0 { + panic("no return value specified for ListColumns") + } + + var r0 []*dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Column, error)); ok { + return rf(ctx, boardID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Column); ok { + r0 = rf(ctx, boardID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, boardID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_ListColumns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListColumns' +type MockBoards_ListColumns_Call struct { + *mock.Call +} + +// ListColumns is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +func (_e *MockBoards_Expecter) ListColumns(ctx interface{}, boardID interface{}) *MockBoards_ListColumns_Call { + return &MockBoards_ListColumns_Call{Call: _e.mock.On("ListColumns", ctx, boardID)} +} + +func (_c *MockBoards_ListColumns_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockBoards_ListColumns_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_ListColumns_Call) Return(_a0 []*dto.Column, _a1 error) *MockBoards_ListColumns_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_ListColumns_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Column, error)) *MockBoards_ListColumns_Call { + _c.Call.Return(run) + return _c +} + +// SetTimer provides a mock function with given fields: ctx, id, minutes +func (_m *MockBoards) SetTimer(ctx context.Context, id uuid.UUID, minutes uint8) (*dto.Board, error) { + ret := _m.Called(ctx, id, minutes) + + if len(ret) == 0 { + panic("no return value specified for SetTimer") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uint8) (*dto.Board, error)); ok { + return rf(ctx, id, minutes) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uint8) *dto.Board); ok { + r0 = rf(ctx, id, minutes) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uint8) error); ok { + r1 = rf(ctx, id, minutes) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_SetTimer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTimer' +type MockBoards_SetTimer_Call struct { + *mock.Call +} + +// SetTimer is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - minutes uint8 +func (_e *MockBoards_Expecter) SetTimer(ctx interface{}, id interface{}, minutes interface{}) *MockBoards_SetTimer_Call { + return &MockBoards_SetTimer_Call{Call: _e.mock.On("SetTimer", ctx, id, minutes)} +} + +func (_c *MockBoards_SetTimer_Call) Run(run func(ctx context.Context, id uuid.UUID, minutes uint8)) *MockBoards_SetTimer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uint8)) + }) + return _c +} + +func (_c *MockBoards_SetTimer_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_SetTimer_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_SetTimer_Call) RunAndReturn(run func(context.Context, uuid.UUID, uint8) (*dto.Board, error)) *MockBoards_SetTimer_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockBoards) Update(ctx context.Context, body dto.BoardUpdateRequest) (*dto.Board, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardUpdateRequest) (*dto.Board, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardUpdateRequest) *dto.Board); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockBoards_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardUpdateRequest +func (_e *MockBoards_Expecter) Update(ctx interface{}, body interface{}) *MockBoards_Update_Call { + return &MockBoards_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockBoards_Update_Call) Run(run func(ctx context.Context, body dto.BoardUpdateRequest)) *MockBoards_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardUpdateRequest)) + }) + return _c +} + +func (_c *MockBoards_Update_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_Update_Call) RunAndReturn(run func(context.Context, dto.BoardUpdateRequest) (*dto.Board, error)) *MockBoards_Update_Call { + _c.Call.Return(run) + return _c +} + +// UpdateColumn provides a mock function with given fields: ctx, body +func (_m *MockBoards) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateColumn") + } + + var r0 *dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) (*dto.Column, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) *dto.Column); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_UpdateColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateColumn' +type MockBoards_UpdateColumn_Call struct { + *mock.Call +} + +// UpdateColumn is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnUpdateRequest +func (_e *MockBoards_Expecter) UpdateColumn(ctx interface{}, body interface{}) *MockBoards_UpdateColumn_Call { + return &MockBoards_UpdateColumn_Call{Call: _e.mock.On("UpdateColumn", ctx, body)} +} + +func (_c *MockBoards_UpdateColumn_Call) Run(run func(ctx context.Context, body dto.ColumnUpdateRequest)) *MockBoards_UpdateColumn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnUpdateRequest)) + }) + return _c +} + +func (_c *MockBoards_UpdateColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_UpdateColumn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_UpdateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnUpdateRequest) (*dto.Column, error)) *MockBoards_UpdateColumn_Call { + _c.Call.Return(run) + return _c +} + +// NewMockBoards creates a new instance of MockBoards. 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 NewMockBoards(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoards { + mock := &MockBoards{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Feedback.go b/server/src/mocks/services/mock_Feedback.go new file mode 100644 index 0000000000..1af1cc0bde --- /dev/null +++ b/server/src/mocks/services/mock_Feedback.go @@ -0,0 +1,130 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// MockFeedback is an autogenerated mock type for the Feedback type +type MockFeedback struct { + mock.Mock +} + +type MockFeedback_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFeedback) EXPECT() *MockFeedback_Expecter { + return &MockFeedback_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, feedbackType, contact, text +func (_m *MockFeedback) Create(ctx context.Context, feedbackType string, contact string, text string) error { + ret := _m.Called(ctx, feedbackType, contact, text) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok { + r0 = rf(ctx, feedbackType, contact, text) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockFeedback_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockFeedback_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - feedbackType string +// - contact string +// - text string +func (_e *MockFeedback_Expecter) Create(ctx interface{}, feedbackType interface{}, contact interface{}, text interface{}) *MockFeedback_Create_Call { + return &MockFeedback_Create_Call{Call: _e.mock.On("Create", ctx, feedbackType, contact, text)} +} + +func (_c *MockFeedback_Create_Call) Run(run func(ctx context.Context, feedbackType string, contact string, text string)) *MockFeedback_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockFeedback_Create_Call) Return(_a0 error) *MockFeedback_Create_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFeedback_Create_Call) RunAndReturn(run func(context.Context, string, string, string) error) *MockFeedback_Create_Call { + _c.Call.Return(run) + return _c +} + +// Enabled provides a mock function with no fields +func (_m *MockFeedback) Enabled() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Enabled") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockFeedback_Enabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Enabled' +type MockFeedback_Enabled_Call struct { + *mock.Call +} + +// Enabled is a helper method to define mock.On call +func (_e *MockFeedback_Expecter) Enabled() *MockFeedback_Enabled_Call { + return &MockFeedback_Enabled_Call{Call: _e.mock.On("Enabled")} +} + +func (_c *MockFeedback_Enabled_Call) Run(run func()) *MockFeedback_Enabled_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockFeedback_Enabled_Call) Return(_a0 bool) *MockFeedback_Enabled_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFeedback_Enabled_Call) RunAndReturn(run func() bool) *MockFeedback_Enabled_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFeedback creates a new instance of MockFeedback. 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 NewMockFeedback(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFeedback { + mock := &MockFeedback{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Health.go b/server/src/mocks/services/mock_Health.go new file mode 100644 index 0000000000..8f4882aa7b --- /dev/null +++ b/server/src/mocks/services/mock_Health.go @@ -0,0 +1,122 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import mock "github.com/stretchr/testify/mock" + +// MockHealth is an autogenerated mock type for the Health type +type MockHealth struct { + mock.Mock +} + +type MockHealth_Expecter struct { + mock *mock.Mock +} + +func (_m *MockHealth) EXPECT() *MockHealth_Expecter { + return &MockHealth_Expecter{mock: &_m.Mock} +} + +// IsDatabaseHealthy provides a mock function with no fields +func (_m *MockHealth) IsDatabaseHealthy() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsDatabaseHealthy") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockHealth_IsDatabaseHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsDatabaseHealthy' +type MockHealth_IsDatabaseHealthy_Call struct { + *mock.Call +} + +// IsDatabaseHealthy is a helper method to define mock.On call +func (_e *MockHealth_Expecter) IsDatabaseHealthy() *MockHealth_IsDatabaseHealthy_Call { + return &MockHealth_IsDatabaseHealthy_Call{Call: _e.mock.On("IsDatabaseHealthy")} +} + +func (_c *MockHealth_IsDatabaseHealthy_Call) Run(run func()) *MockHealth_IsDatabaseHealthy_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockHealth_IsDatabaseHealthy_Call) Return(_a0 bool) *MockHealth_IsDatabaseHealthy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHealth_IsDatabaseHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsDatabaseHealthy_Call { + _c.Call.Return(run) + return _c +} + +// IsRealtimeHealthy provides a mock function with no fields +func (_m *MockHealth) IsRealtimeHealthy() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsRealtimeHealthy") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockHealth_IsRealtimeHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRealtimeHealthy' +type MockHealth_IsRealtimeHealthy_Call struct { + *mock.Call +} + +// IsRealtimeHealthy is a helper method to define mock.On call +func (_e *MockHealth_Expecter) IsRealtimeHealthy() *MockHealth_IsRealtimeHealthy_Call { + return &MockHealth_IsRealtimeHealthy_Call{Call: _e.mock.On("IsRealtimeHealthy")} +} + +func (_c *MockHealth_IsRealtimeHealthy_Call) Run(run func()) *MockHealth_IsRealtimeHealthy_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockHealth_IsRealtimeHealthy_Call) Return(_a0 bool) *MockHealth_IsRealtimeHealthy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHealth_IsRealtimeHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsRealtimeHealthy_Call { + _c.Call.Return(run) + return _c +} + +// NewMockHealth creates a new instance of MockHealth. 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 NewMockHealth(t interface { + mock.TestingT + Cleanup(func()) +}) *MockHealth { + mock := &MockHealth{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Notes.go b/server/src/mocks/services/mock_Notes.go new file mode 100644 index 0000000000..66024de389 --- /dev/null +++ b/server/src/mocks/services/mock_Notes.go @@ -0,0 +1,382 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockNotes is an autogenerated mock type for the Notes type +type MockNotes struct { + mock.Mock +} + +type MockNotes_Expecter struct { + mock *mock.Mock +} + +func (_m *MockNotes) EXPECT() *MockNotes_Expecter { + return &MockNotes_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteCreateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockNotes_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteCreateRequest +func (_e *MockNotes_Expecter) Create(ctx interface{}, body interface{}) *MockNotes_Create_Call { + return &MockNotes_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockNotes_Create_Call) Run(run func(ctx context.Context, body dto.NoteCreateRequest)) *MockNotes_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteCreateRequest)) + }) + return _c +} + +func (_c *MockNotes_Create_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)) *MockNotes_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, body, id +func (_m *MockNotes) Delete(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID) error { + ret := _m.Called(ctx, body, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error); ok { + r0 = rf(ctx, body, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockNotes_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockNotes_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteDeleteRequest +// - id uuid.UUID +func (_e *MockNotes_Expecter) Delete(ctx interface{}, body interface{}, id interface{}) *MockNotes_Delete_Call { + return &MockNotes_Delete_Call{Call: _e.mock.On("Delete", ctx, body, id)} +} + +func (_c *MockNotes_Delete_Call) Run(run func(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID)) *MockNotes_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteDeleteRequest), args[2].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Delete_Call) Return(_a0 error) *MockNotes_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotes_Delete_Call) RunAndReturn(run func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error) *MockNotes_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockNotes_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) Get(ctx interface{}, id interface{}) *MockNotes_Get_Call { + return &MockNotes_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockNotes_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Get_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Note, error)) *MockNotes_Get_Call { + _c.Call.Return(run) + return _c +} + +// Import provides a mock function with given fields: ctx, body +func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Import") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteImportRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Import_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Import' +type MockNotes_Import_Call struct { + *mock.Call +} + +// Import is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteImportRequest +func (_e *MockNotes_Expecter) Import(ctx interface{}, body interface{}) *MockNotes_Import_Call { + return &MockNotes_Import_Call{Call: _e.mock.On("Import", ctx, body)} +} + +func (_c *MockNotes_Import_Call) Run(run func(ctx context.Context, body dto.NoteImportRequest)) *MockNotes_Import_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteImportRequest)) + }) + return _c +} + +func (_c *MockNotes_Import_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Import_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*dto.Note, error)) *MockNotes_Import_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, id +func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockNotes_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) List(ctx interface{}, id interface{}) *MockNotes_List_Call { + return &MockNotes_List_Call{Call: _e.mock.On("List", ctx, id)} +} + +func (_c *MockNotes_List_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_List_Call) Return(_a0 []*dto.Note, _a1 error) *MockNotes_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Note, error)) *MockNotes_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockNotes_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteUpdateRequest +func (_e *MockNotes_Expecter) Update(ctx interface{}, body interface{}) *MockNotes_Update_Call { + return &MockNotes_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockNotes_Update_Call) Run(run func(ctx context.Context, body dto.NoteUpdateRequest)) *MockNotes_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteUpdateRequest)) + }) + return _c +} + +func (_c *MockNotes_Update_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)) *MockNotes_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockNotes creates a new instance of MockNotes. 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 NewMockNotes(t interface { + mock.TestingT + Cleanup(func()) +}) *MockNotes { + mock := &MockNotes{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Reactions.go b/server/src/mocks/services/mock_Reactions.go new file mode 100644 index 0000000000..d798028a82 --- /dev/null +++ b/server/src/mocks/services/mock_Reactions.go @@ -0,0 +1,328 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockReactions is an autogenerated mock type for the Reactions type +type MockReactions struct { + mock.Mock +} + +type MockReactions_Expecter struct { + mock *mock.Mock +} + +func (_m *MockReactions) EXPECT() *MockReactions_Expecter { + return &MockReactions_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, board, body +func (_m *MockReactions) Create(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest) (*dto.Reaction, error) { + ret := _m.Called(ctx, board, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)); ok { + return rf(ctx, board, body) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) *dto.Reaction); ok { + r0 = rf(ctx, board, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) error); ok { + r1 = rf(ctx, board, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockReactions_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - body dto.ReactionCreateRequest +func (_e *MockReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockReactions_Create_Call { + return &MockReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} +} + +func (_c *MockReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest)) *MockReactions_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.ReactionCreateRequest)) + }) + return _c +} + +func (_c *MockReactions_Create_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)) *MockReactions_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, board, user, id +func (_m *MockReactions) Delete(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID) error { + ret := _m.Called(ctx, board, user, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, board, user, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockReactions_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockReactions_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - user uuid.UUID +// - id uuid.UUID +func (_e *MockReactions_Expecter) Delete(ctx interface{}, board interface{}, user interface{}, id interface{}) *MockReactions_Delete_Call { + return &MockReactions_Delete_Call{Call: _e.mock.On("Delete", ctx, board, user, id)} +} + +func (_c *MockReactions_Delete_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID)) *MockReactions_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) + }) + return _c +} + +func (_c *MockReactions_Delete_Call) Return(_a0 error) *MockReactions_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockReactions_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockReactions_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockReactions) Get(ctx context.Context, id uuid.UUID) (*dto.Reaction, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Reaction, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Reaction); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockReactions_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockReactions_Expecter) Get(ctx interface{}, id interface{}) *MockReactions_Get_Call { + return &MockReactions_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockReactions_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockReactions_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockReactions_Get_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Reaction, error)) *MockReactions_Get_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, boardID +func (_m *MockReactions) List(ctx context.Context, boardID uuid.UUID) ([]*dto.Reaction, error) { + ret := _m.Called(ctx, boardID) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Reaction, error)); ok { + return rf(ctx, boardID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Reaction); ok { + r0 = rf(ctx, boardID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, boardID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockReactions_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +func (_e *MockReactions_Expecter) List(ctx interface{}, boardID interface{}) *MockReactions_List_Call { + return &MockReactions_List_Call{Call: _e.mock.On("List", ctx, boardID)} +} + +func (_c *MockReactions_List_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockReactions_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockReactions_List_Call) Return(_a0 []*dto.Reaction, _a1 error) *MockReactions_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Reaction, error)) *MockReactions_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, board, user, id, body +func (_m *MockReactions) Update(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest) (*dto.Reaction, error) { + ret := _m.Called(ctx, board, user, id, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)); ok { + return rf(ctx, board, user, id, body) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) *dto.Reaction); ok { + r0 = rf(ctx, board, user, id, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) error); ok { + r1 = rf(ctx, board, user, id, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockReactions_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - user uuid.UUID +// - id uuid.UUID +// - body dto.ReactionUpdateTypeRequest +func (_e *MockReactions_Expecter) Update(ctx interface{}, board interface{}, user interface{}, id interface{}, body interface{}) *MockReactions_Update_Call { + return &MockReactions_Update_Call{Call: _e.mock.On("Update", ctx, board, user, id, body)} +} + +func (_c *MockReactions_Update_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest)) *MockReactions_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID), args[4].(dto.ReactionUpdateTypeRequest)) + }) + return _c +} + +func (_c *MockReactions_Update_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_Update_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)) *MockReactions_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockReactions creates a new instance of MockReactions. 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 NewMockReactions(t interface { + mock.TestingT + Cleanup(func()) +}) *MockReactions { + mock := &MockReactions{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Users.go b/server/src/mocks/services/mock_Users.go new file mode 100644 index 0000000000..e5e9855981 --- /dev/null +++ b/server/src/mocks/services/mock_Users.go @@ -0,0 +1,582 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockUsers is an autogenerated mock type for the Users type +type MockUsers struct { + mock.Mock +} + +type MockUsers_Expecter struct { + mock *mock.Mock +} + +func (_m *MockUsers) EXPECT() *MockUsers_Expecter { + return &MockUsers_Expecter{mock: &_m.Mock} +} + +// CreateAppleUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateAppleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateAppleUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateAppleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAppleUser' +type MockUsers_CreateAppleUser_Call struct { + *mock.Call +} + +// CreateAppleUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateAppleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAppleUser_Call { + return &MockUsers_CreateAppleUser_Call{Call: _e.mock.On("CreateAppleUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateAppleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAppleUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateAppleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAppleUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateAppleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAppleUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateAzureAdUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateAzureAdUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateAzureAdUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateAzureAdUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAzureAdUser' +type MockUsers_CreateAzureAdUser_Call struct { + *mock.Call +} + +// CreateAzureAdUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateAzureAdUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAzureAdUser_Call { + return &MockUsers_CreateAzureAdUser_Call{Call: _e.mock.On("CreateAzureAdUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateAzureAdUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAzureAdUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateAzureAdUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAzureAdUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateAzureAdUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAzureAdUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateGitHubUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateGitHubUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateGitHubUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateGitHubUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGitHubUser' +type MockUsers_CreateGitHubUser_Call struct { + *mock.Call +} + +// CreateGitHubUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateGitHubUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGitHubUser_Call { + return &MockUsers_CreateGitHubUser_Call{Call: _e.mock.On("CreateGitHubUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateGitHubUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGitHubUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateGitHubUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGitHubUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateGitHubUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGitHubUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateGoogleUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateGoogleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateGoogleUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateGoogleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGoogleUser' +type MockUsers_CreateGoogleUser_Call struct { + *mock.Call +} + +// CreateGoogleUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateGoogleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGoogleUser_Call { + return &MockUsers_CreateGoogleUser_Call{Call: _e.mock.On("CreateGoogleUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateGoogleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGoogleUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateGoogleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGoogleUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateGoogleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGoogleUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateMicrosoftUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateMicrosoftUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateMicrosoftUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateMicrosoftUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMicrosoftUser' +type MockUsers_CreateMicrosoftUser_Call struct { + *mock.Call +} + +// CreateMicrosoftUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateMicrosoftUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateMicrosoftUser_Call { + return &MockUsers_CreateMicrosoftUser_Call{Call: _e.mock.On("CreateMicrosoftUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateMicrosoftUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateMicrosoftUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateMicrosoftUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateMicrosoftUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateMicrosoftUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateMicrosoftUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateOIDCUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateOIDCUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateOIDCUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateOIDCUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOIDCUser' +type MockUsers_CreateOIDCUser_Call struct { + *mock.Call +} + +// CreateOIDCUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateOIDCUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateOIDCUser_Call { + return &MockUsers_CreateOIDCUser_Call{Call: _e.mock.On("CreateOIDCUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateOIDCUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateOIDCUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateOIDCUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateOIDCUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateOIDCUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateOIDCUser_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockUsers) Get(ctx context.Context, id uuid.UUID) (*dto.User, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.User, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.User); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockUsers_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockUsers_Expecter) Get(ctx interface{}, id interface{}) *MockUsers_Get_Call { + return &MockUsers_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockUsers_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockUsers_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockUsers_Get_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.User, error)) *MockUsers_Get_Call { + _c.Call.Return(run) + return _c +} + +// LoginAnonymous provides a mock function with given fields: ctx, name +func (_m *MockUsers) LoginAnonymous(ctx context.Context, name string) (*dto.User, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for LoginAnonymous") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*dto.User, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *dto.User); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_LoginAnonymous_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoginAnonymous' +type MockUsers_LoginAnonymous_Call struct { + *mock.Call +} + +// LoginAnonymous is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockUsers_Expecter) LoginAnonymous(ctx interface{}, name interface{}) *MockUsers_LoginAnonymous_Call { + return &MockUsers_LoginAnonymous_Call{Call: _e.mock.On("LoginAnonymous", ctx, name)} +} + +func (_c *MockUsers_LoginAnonymous_Call) Run(run func(ctx context.Context, name string)) *MockUsers_LoginAnonymous_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockUsers_LoginAnonymous_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_LoginAnonymous_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_LoginAnonymous_Call) RunAndReturn(run func(context.Context, string) (*dto.User, error)) *MockUsers_LoginAnonymous_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockUsers) Update(ctx context.Context, body dto.UserUpdateRequest) (*dto.User, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) (*dto.User, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) *dto.User); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.UserUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockUsers_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.UserUpdateRequest +func (_e *MockUsers_Expecter) Update(ctx interface{}, body interface{}) *MockUsers_Update_Call { + return &MockUsers_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockUsers_Update_Call) Run(run func(ctx context.Context, body dto.UserUpdateRequest)) *MockUsers_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.UserUpdateRequest)) + }) + return _c +} + +func (_c *MockUsers_Update_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_Update_Call) RunAndReturn(run func(context.Context, dto.UserUpdateRequest) (*dto.User, error)) *MockUsers_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockUsers creates a new instance of MockUsers. 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 NewMockUsers(t interface { + mock.TestingT + Cleanup(func()) +}) *MockUsers { + mock := &MockUsers{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 +} From f8b418e42a243679085999a3e41f2d1e5462d786 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 16:18:47 +0100 Subject: [PATCH 07/27] chore: generate only needed mocks and adapt readme for mockery --- server/README.md | 20 +- server/src/.mockery.yaml | 9 +- .../src/mocks/services/mock_BoardReactions.go | 74 --- .../src/mocks/services/mock_BoardTemplates.go | 608 ------------------ server/src/mocks/services/mock_Feedback.go | 130 ---- server/src/mocks/services/mock_Health.go | 122 ---- server/src/mocks/services/mock_Notes.go | 382 ----------- server/src/mocks/services/mock_Reactions.go | 328 ---------- server/src/mocks/services/mock_Users.go | 582 ----------------- server/src/mocks/services/mock_Votings.go | 443 ------------- 10 files changed, 24 insertions(+), 2674 deletions(-) delete mode 100644 server/src/mocks/services/mock_BoardReactions.go delete mode 100644 server/src/mocks/services/mock_BoardTemplates.go delete mode 100644 server/src/mocks/services/mock_Feedback.go delete mode 100644 server/src/mocks/services/mock_Health.go delete mode 100644 server/src/mocks/services/mock_Notes.go delete mode 100644 server/src/mocks/services/mock_Reactions.go delete mode 100644 server/src/mocks/services/mock_Users.go delete mode 100644 server/src/mocks/services/mock_Votings.go diff --git a/server/README.md b/server/README.md index b72c66ce6e..bb4427dbf9 100644 --- a/server/README.md +++ b/server/README.md @@ -23,7 +23,7 @@ can also be set by environment variables so you don't have to worry about the ru each time. ## Configuration via TOML file -You can also configure the server using a TOML file. To do this, pass the `--config` flag to the server executable, followed by the path to the TOML file. +You can also configure the server using a TOML file. To do this, pass the `--config` flag to the server executable, followed by the path to the TOML file. For example, to configure the server using a file named `config_example.toml`, you would run the following command: @@ -31,7 +31,7 @@ For example, to configure the server using a file named `config_example.toml`, y go run . --config config_example.toml ``` -To see all values that can be set and what purpose they serve, take a look at the provided `config_example.toml` file. +To see all values that can be set and what purpose they serve, take a look at the provided `config_example.toml` file. ## API @@ -41,3 +41,19 @@ resources and take a look at our documentation. Currently, you can also just open your browser on [http://localhost:8080](http://localhost:8080) to see our debug client. We'll disable it once everything got stable. + + +## Testing and Mockery + +At a certain point, it is more convenient to use a framework to generate mocks for interfaces. +This is where the use of Mockery comes into play (https://vektra.github.io/mockery/latest/installation/). +Depending on the operating system (macOS via Homebrew), +install Mockery and run it in the directory with .mockery.yaml (mockery). The mocks in the mocks directory will be automatically regenerated. + +```bash +# switch to src directory +# and just run mockery to refresh the mocks +mockery +``` + +Configuration of mockery is described in the .mockery.yaml file. diff --git a/server/src/.mockery.yaml b/server/src/.mockery.yaml index c26a0bf520..d8aca0eb11 100644 --- a/server/src/.mockery.yaml +++ b/server/src/.mockery.yaml @@ -8,6 +8,9 @@ issue-845-fix: true packages: # configuration on package level scrumlr.io/server/services: - config: - # generate for all interfaces in services a mock (for example: mock_Boards) - all: true + # configuration on interface level + interfaces: + Boards: + all: true + BoardSessions: + all: true diff --git a/server/src/mocks/services/mock_BoardReactions.go b/server/src/mocks/services/mock_BoardReactions.go deleted file mode 100644 index 0eee513361..0000000000 --- a/server/src/mocks/services/mock_BoardReactions.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockBoardReactions is an autogenerated mock type for the BoardReactions type -type MockBoardReactions struct { - mock.Mock -} - -type MockBoardReactions_Expecter struct { - mock *mock.Mock -} - -func (_m *MockBoardReactions) EXPECT() *MockBoardReactions_Expecter { - return &MockBoardReactions_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, board, body -func (_m *MockBoardReactions) Create(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest) { - _m.Called(ctx, board, body) -} - -// MockBoardReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockBoardReactions_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - body dto.BoardReactionCreateRequest -func (_e *MockBoardReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockBoardReactions_Create_Call { - return &MockBoardReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} -} - -func (_c *MockBoardReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.BoardReactionCreateRequest)) - }) - return _c -} - -func (_c *MockBoardReactions_Create_Call) Return() *MockBoardReactions_Create_Call { - _c.Call.Return() - return _c -} - -func (_c *MockBoardReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { - _c.Run(run) - return _c -} - -// NewMockBoardReactions creates a new instance of MockBoardReactions. 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 NewMockBoardReactions(t interface { - mock.TestingT - Cleanup(func()) -}) *MockBoardReactions { - mock := &MockBoardReactions{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_BoardTemplates.go b/server/src/mocks/services/mock_BoardTemplates.go deleted file mode 100644 index 5511784877..0000000000 --- a/server/src/mocks/services/mock_BoardTemplates.go +++ /dev/null @@ -1,608 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockBoardTemplates is an autogenerated mock type for the BoardTemplates type -type MockBoardTemplates struct { - mock.Mock -} - -type MockBoardTemplates_Expecter struct { - mock *mock.Mock -} - -func (_m *MockBoardTemplates) EXPECT() *MockBoardTemplates_Expecter { - return &MockBoardTemplates_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) Create(ctx context.Context, body dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *dto.BoardTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) *dto.BoardTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.BoardTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.CreateBoardTemplateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockBoardTemplates_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - body dto.CreateBoardTemplateRequest -func (_e *MockBoardTemplates_Expecter) Create(ctx interface{}, body interface{}) *MockBoardTemplates_Create_Call { - return &MockBoardTemplates_Create_Call{Call: _e.mock.On("Create", ctx, body)} -} - -func (_c *MockBoardTemplates_Create_Call) Run(run func(ctx context.Context, body dto.CreateBoardTemplateRequest)) *MockBoardTemplates_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.CreateBoardTemplateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_Create_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_Create_Call) RunAndReturn(run func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Create_Call { - _c.Call.Return(run) - return _c -} - -// CreateColumnTemplate provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) CreateColumnTemplate(ctx context.Context, body dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for CreateColumnTemplate") - } - - var r0 *dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) *dto.ColumnTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.ColumnTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_CreateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateColumnTemplate' -type MockBoardTemplates_CreateColumnTemplate_Call struct { - *mock.Call -} - -// CreateColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - body dto.ColumnTemplateRequest -func (_e *MockBoardTemplates_Expecter) CreateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_CreateColumnTemplate_Call { - return &MockBoardTemplates_CreateColumnTemplate_Call{Call: _e.mock.On("CreateColumnTemplate", ctx, body)} -} - -func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateRequest)) *MockBoardTemplates_CreateColumnTemplate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.ColumnTemplateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_CreateColumnTemplate_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_CreateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_CreateColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function with given fields: ctx, id -func (_m *MockBoardTemplates) Delete(ctx context.Context, id uuid.UUID) error { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok { - r0 = rf(ctx, id) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockBoardTemplates_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type MockBoardTemplates_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockBoardTemplates_Expecter) Delete(ctx interface{}, id interface{}) *MockBoardTemplates_Delete_Call { - return &MockBoardTemplates_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} -} - -func (_c *MockBoardTemplates_Delete_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_Delete_Call) Return(_a0 error) *MockBoardTemplates_Delete_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBoardTemplates_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID) error) *MockBoardTemplates_Delete_Call { - _c.Call.Return(run) - return _c -} - -// DeleteColumnTemplate provides a mock function with given fields: ctx, boar, column, user -func (_m *MockBoardTemplates) DeleteColumnTemplate(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID) error { - ret := _m.Called(ctx, boar, column, user) - - if len(ret) == 0 { - panic("no return value specified for DeleteColumnTemplate") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { - r0 = rf(ctx, boar, column, user) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockBoardTemplates_DeleteColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteColumnTemplate' -type MockBoardTemplates_DeleteColumnTemplate_Call struct { - *mock.Call -} - -// DeleteColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - boar uuid.UUID -// - column uuid.UUID -// - user uuid.UUID -func (_e *MockBoardTemplates_Expecter) DeleteColumnTemplate(ctx interface{}, boar interface{}, column interface{}, user interface{}) *MockBoardTemplates_DeleteColumnTemplate_Call { - return &MockBoardTemplates_DeleteColumnTemplate_Call{Call: _e.mock.On("DeleteColumnTemplate", ctx, boar, column, user)} -} - -func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Run(run func(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID)) *MockBoardTemplates_DeleteColumnTemplate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Return(_a0 error) *MockBoardTemplates_DeleteColumnTemplate_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockBoardTemplates_DeleteColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockBoardTemplates) Get(ctx context.Context, id uuid.UUID) (*dto.BoardTemplate, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.BoardTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.BoardTemplate); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.BoardTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockBoardTemplates_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockBoardTemplates_Expecter) Get(ctx interface{}, id interface{}) *MockBoardTemplates_Get_Call { - return &MockBoardTemplates_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockBoardTemplates_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_Get_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)) *MockBoardTemplates_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetColumnTemplate provides a mock function with given fields: ctx, boardID, columnID -func (_m *MockBoardTemplates) GetColumnTemplate(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, boardID, columnID) - - if len(ret) == 0 { - panic("no return value specified for GetColumnTemplate") - } - - var r0 *dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)); ok { - return rf(ctx, boardID, columnID) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.ColumnTemplate); ok { - r0 = rf(ctx, boardID, columnID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.ColumnTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { - r1 = rf(ctx, boardID, columnID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_GetColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetColumnTemplate' -type MockBoardTemplates_GetColumnTemplate_Call struct { - *mock.Call -} - -// GetColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - boardID uuid.UUID -// - columnID uuid.UUID -func (_e *MockBoardTemplates_Expecter) GetColumnTemplate(ctx interface{}, boardID interface{}, columnID interface{}) *MockBoardTemplates_GetColumnTemplate_Call { - return &MockBoardTemplates_GetColumnTemplate_Call{Call: _e.mock.On("GetColumnTemplate", ctx, boardID, columnID)} -} - -func (_c *MockBoardTemplates_GetColumnTemplate_Call) Run(run func(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID)) *MockBoardTemplates_GetColumnTemplate_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 *MockBoardTemplates_GetColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_GetColumnTemplate_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_GetColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)) *MockBoardTemplates_GetColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function with given fields: ctx, user -func (_m *MockBoardTemplates) List(ctx context.Context, user uuid.UUID) ([]*dto.BoardTemplateFull, error) { - ret := _m.Called(ctx, user) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*dto.BoardTemplateFull - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)); ok { - return rf(ctx, user) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.BoardTemplateFull); ok { - r0 = rf(ctx, user) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.BoardTemplateFull) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, user) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockBoardTemplates_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - user uuid.UUID -func (_e *MockBoardTemplates_Expecter) List(ctx interface{}, user interface{}) *MockBoardTemplates_List_Call { - return &MockBoardTemplates_List_Call{Call: _e.mock.On("List", ctx, user)} -} - -func (_c *MockBoardTemplates_List_Call) Run(run func(ctx context.Context, user uuid.UUID)) *MockBoardTemplates_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_List_Call) Return(_a0 []*dto.BoardTemplateFull, _a1 error) *MockBoardTemplates_List_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)) *MockBoardTemplates_List_Call { - _c.Call.Return(run) - return _c -} - -// ListColumnTemplates provides a mock function with given fields: ctx, board -func (_m *MockBoardTemplates) ListColumnTemplates(ctx context.Context, board uuid.UUID) ([]*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, board) - - if len(ret) == 0 { - panic("no return value specified for ListColumnTemplates") - } - - var r0 []*dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)); ok { - return rf(ctx, board) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.ColumnTemplate); ok { - r0 = rf(ctx, board) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.ColumnTemplate) - } - } - - 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 -} - -// MockBoardTemplates_ListColumnTemplates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListColumnTemplates' -type MockBoardTemplates_ListColumnTemplates_Call struct { - *mock.Call -} - -// ListColumnTemplates is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -func (_e *MockBoardTemplates_Expecter) ListColumnTemplates(ctx interface{}, board interface{}) *MockBoardTemplates_ListColumnTemplates_Call { - return &MockBoardTemplates_ListColumnTemplates_Call{Call: _e.mock.On("ListColumnTemplates", ctx, board)} -} - -func (_c *MockBoardTemplates_ListColumnTemplates_Call) Run(run func(ctx context.Context, board uuid.UUID)) *MockBoardTemplates_ListColumnTemplates_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_ListColumnTemplates_Call) Return(_a0 []*dto.ColumnTemplate, _a1 error) *MockBoardTemplates_ListColumnTemplates_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_ListColumnTemplates_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)) *MockBoardTemplates_ListColumnTemplates_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) Update(ctx context.Context, body dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.BoardTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) *dto.BoardTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.BoardTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.BoardTemplateUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockBoardTemplates_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - body dto.BoardTemplateUpdateRequest -func (_e *MockBoardTemplates_Expecter) Update(ctx interface{}, body interface{}) *MockBoardTemplates_Update_Call { - return &MockBoardTemplates_Update_Call{Call: _e.mock.On("Update", ctx, body)} -} - -func (_c *MockBoardTemplates_Update_Call) Run(run func(ctx context.Context, body dto.BoardTemplateUpdateRequest)) *MockBoardTemplates_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.BoardTemplateUpdateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_Update_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_Update_Call) RunAndReturn(run func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Update_Call { - _c.Call.Return(run) - return _c -} - -// UpdateColumnTemplate provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) UpdateColumnTemplate(ctx context.Context, body dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for UpdateColumnTemplate") - } - - var r0 *dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) *dto.ColumnTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.ColumnTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_UpdateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateColumnTemplate' -type MockBoardTemplates_UpdateColumnTemplate_Call struct { - *mock.Call -} - -// UpdateColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - body dto.ColumnTemplateUpdateRequest -func (_e *MockBoardTemplates_Expecter) UpdateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_UpdateColumnTemplate_Call { - return &MockBoardTemplates_UpdateColumnTemplate_Call{Call: _e.mock.On("UpdateColumnTemplate", ctx, body)} -} - -func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateUpdateRequest)) *MockBoardTemplates_UpdateColumnTemplate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.ColumnTemplateUpdateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_UpdateColumnTemplate_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_UpdateColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// NewMockBoardTemplates creates a new instance of MockBoardTemplates. 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 NewMockBoardTemplates(t interface { - mock.TestingT - Cleanup(func()) -}) *MockBoardTemplates { - mock := &MockBoardTemplates{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Feedback.go b/server/src/mocks/services/mock_Feedback.go deleted file mode 100644 index 1af1cc0bde..0000000000 --- a/server/src/mocks/services/mock_Feedback.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// MockFeedback is an autogenerated mock type for the Feedback type -type MockFeedback struct { - mock.Mock -} - -type MockFeedback_Expecter struct { - mock *mock.Mock -} - -func (_m *MockFeedback) EXPECT() *MockFeedback_Expecter { - return &MockFeedback_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, feedbackType, contact, text -func (_m *MockFeedback) Create(ctx context.Context, feedbackType string, contact string, text string) error { - ret := _m.Called(ctx, feedbackType, contact, text) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok { - r0 = rf(ctx, feedbackType, contact, text) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockFeedback_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockFeedback_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - feedbackType string -// - contact string -// - text string -func (_e *MockFeedback_Expecter) Create(ctx interface{}, feedbackType interface{}, contact interface{}, text interface{}) *MockFeedback_Create_Call { - return &MockFeedback_Create_Call{Call: _e.mock.On("Create", ctx, feedbackType, contact, text)} -} - -func (_c *MockFeedback_Create_Call) Run(run func(ctx context.Context, feedbackType string, contact string, text string)) *MockFeedback_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockFeedback_Create_Call) Return(_a0 error) *MockFeedback_Create_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFeedback_Create_Call) RunAndReturn(run func(context.Context, string, string, string) error) *MockFeedback_Create_Call { - _c.Call.Return(run) - return _c -} - -// Enabled provides a mock function with no fields -func (_m *MockFeedback) Enabled() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Enabled") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockFeedback_Enabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Enabled' -type MockFeedback_Enabled_Call struct { - *mock.Call -} - -// Enabled is a helper method to define mock.On call -func (_e *MockFeedback_Expecter) Enabled() *MockFeedback_Enabled_Call { - return &MockFeedback_Enabled_Call{Call: _e.mock.On("Enabled")} -} - -func (_c *MockFeedback_Enabled_Call) Run(run func()) *MockFeedback_Enabled_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFeedback_Enabled_Call) Return(_a0 bool) *MockFeedback_Enabled_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFeedback_Enabled_Call) RunAndReturn(run func() bool) *MockFeedback_Enabled_Call { - _c.Call.Return(run) - return _c -} - -// NewMockFeedback creates a new instance of MockFeedback. 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 NewMockFeedback(t interface { - mock.TestingT - Cleanup(func()) -}) *MockFeedback { - mock := &MockFeedback{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Health.go b/server/src/mocks/services/mock_Health.go deleted file mode 100644 index 8f4882aa7b..0000000000 --- a/server/src/mocks/services/mock_Health.go +++ /dev/null @@ -1,122 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import mock "github.com/stretchr/testify/mock" - -// MockHealth is an autogenerated mock type for the Health type -type MockHealth struct { - mock.Mock -} - -type MockHealth_Expecter struct { - mock *mock.Mock -} - -func (_m *MockHealth) EXPECT() *MockHealth_Expecter { - return &MockHealth_Expecter{mock: &_m.Mock} -} - -// IsDatabaseHealthy provides a mock function with no fields -func (_m *MockHealth) IsDatabaseHealthy() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsDatabaseHealthy") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockHealth_IsDatabaseHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsDatabaseHealthy' -type MockHealth_IsDatabaseHealthy_Call struct { - *mock.Call -} - -// IsDatabaseHealthy is a helper method to define mock.On call -func (_e *MockHealth_Expecter) IsDatabaseHealthy() *MockHealth_IsDatabaseHealthy_Call { - return &MockHealth_IsDatabaseHealthy_Call{Call: _e.mock.On("IsDatabaseHealthy")} -} - -func (_c *MockHealth_IsDatabaseHealthy_Call) Run(run func()) *MockHealth_IsDatabaseHealthy_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockHealth_IsDatabaseHealthy_Call) Return(_a0 bool) *MockHealth_IsDatabaseHealthy_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockHealth_IsDatabaseHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsDatabaseHealthy_Call { - _c.Call.Return(run) - return _c -} - -// IsRealtimeHealthy provides a mock function with no fields -func (_m *MockHealth) IsRealtimeHealthy() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsRealtimeHealthy") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockHealth_IsRealtimeHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRealtimeHealthy' -type MockHealth_IsRealtimeHealthy_Call struct { - *mock.Call -} - -// IsRealtimeHealthy is a helper method to define mock.On call -func (_e *MockHealth_Expecter) IsRealtimeHealthy() *MockHealth_IsRealtimeHealthy_Call { - return &MockHealth_IsRealtimeHealthy_Call{Call: _e.mock.On("IsRealtimeHealthy")} -} - -func (_c *MockHealth_IsRealtimeHealthy_Call) Run(run func()) *MockHealth_IsRealtimeHealthy_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockHealth_IsRealtimeHealthy_Call) Return(_a0 bool) *MockHealth_IsRealtimeHealthy_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockHealth_IsRealtimeHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsRealtimeHealthy_Call { - _c.Call.Return(run) - return _c -} - -// NewMockHealth creates a new instance of MockHealth. 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 NewMockHealth(t interface { - mock.TestingT - Cleanup(func()) -}) *MockHealth { - mock := &MockHealth{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Notes.go b/server/src/mocks/services/mock_Notes.go deleted file mode 100644 index 66024de389..0000000000 --- a/server/src/mocks/services/mock_Notes.go +++ /dev/null @@ -1,382 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockNotes is an autogenerated mock type for the Notes type -type MockNotes struct { - mock.Mock -} - -type MockNotes_Expecter struct { - mock *mock.Mock -} - -func (_m *MockNotes) EXPECT() *MockNotes_Expecter { - return &MockNotes_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, body -func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*dto.Note, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *dto.Note); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.NoteCreateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockNotes_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteCreateRequest -func (_e *MockNotes_Expecter) Create(ctx interface{}, body interface{}) *MockNotes_Create_Call { - return &MockNotes_Create_Call{Call: _e.mock.On("Create", ctx, body)} -} - -func (_c *MockNotes_Create_Call) Run(run func(ctx context.Context, body dto.NoteCreateRequest)) *MockNotes_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteCreateRequest)) - }) - return _c -} - -func (_c *MockNotes_Create_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)) *MockNotes_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function with given fields: ctx, body, id -func (_m *MockNotes) Delete(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID) error { - ret := _m.Called(ctx, body, id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error); ok { - r0 = rf(ctx, body, id) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockNotes_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type MockNotes_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteDeleteRequest -// - id uuid.UUID -func (_e *MockNotes_Expecter) Delete(ctx interface{}, body interface{}, id interface{}) *MockNotes_Delete_Call { - return &MockNotes_Delete_Call{Call: _e.mock.On("Delete", ctx, body, id)} -} - -func (_c *MockNotes_Delete_Call) Run(run func(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID)) *MockNotes_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteDeleteRequest), args[2].(uuid.UUID)) - }) - return _c -} - -func (_c *MockNotes_Delete_Call) Return(_a0 error) *MockNotes_Delete_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockNotes_Delete_Call) RunAndReturn(run func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error) *MockNotes_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Note, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Note); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockNotes_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockNotes_Expecter) Get(ctx interface{}, id interface{}) *MockNotes_Get_Call { - return &MockNotes_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockNotes_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockNotes_Get_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Note, error)) *MockNotes_Get_Call { - _c.Call.Return(run) - return _c -} - -// Import provides a mock function with given fields: ctx, body -func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*dto.Note, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Import") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*dto.Note, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *dto.Note); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.NoteImportRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Import_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Import' -type MockNotes_Import_Call struct { - *mock.Call -} - -// Import is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteImportRequest -func (_e *MockNotes_Expecter) Import(ctx interface{}, body interface{}) *MockNotes_Import_Call { - return &MockNotes_Import_Call{Call: _e.mock.On("Import", ctx, body)} -} - -func (_c *MockNotes_Import_Call) Run(run func(ctx context.Context, body dto.NoteImportRequest)) *MockNotes_Import_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteImportRequest)) - }) - return _c -} - -func (_c *MockNotes_Import_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Import_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*dto.Note, error)) *MockNotes_Import_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function with given fields: ctx, id -func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*dto.Note, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Note, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Note); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockNotes_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockNotes_Expecter) List(ctx interface{}, id interface{}) *MockNotes_List_Call { - return &MockNotes_List_Call{Call: _e.mock.On("List", ctx, id)} -} - -func (_c *MockNotes_List_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockNotes_List_Call) Return(_a0 []*dto.Note, _a1 error) *MockNotes_List_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Note, error)) *MockNotes_List_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, body -func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*dto.Note, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *dto.Note); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.NoteUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockNotes_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteUpdateRequest -func (_e *MockNotes_Expecter) Update(ctx interface{}, body interface{}) *MockNotes_Update_Call { - return &MockNotes_Update_Call{Call: _e.mock.On("Update", ctx, body)} -} - -func (_c *MockNotes_Update_Call) Run(run func(ctx context.Context, body dto.NoteUpdateRequest)) *MockNotes_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteUpdateRequest)) - }) - return _c -} - -func (_c *MockNotes_Update_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)) *MockNotes_Update_Call { - _c.Call.Return(run) - return _c -} - -// NewMockNotes creates a new instance of MockNotes. 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 NewMockNotes(t interface { - mock.TestingT - Cleanup(func()) -}) *MockNotes { - mock := &MockNotes{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Reactions.go b/server/src/mocks/services/mock_Reactions.go deleted file mode 100644 index d798028a82..0000000000 --- a/server/src/mocks/services/mock_Reactions.go +++ /dev/null @@ -1,328 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockReactions is an autogenerated mock type for the Reactions type -type MockReactions struct { - mock.Mock -} - -type MockReactions_Expecter struct { - mock *mock.Mock -} - -func (_m *MockReactions) EXPECT() *MockReactions_Expecter { - return &MockReactions_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, board, body -func (_m *MockReactions) Create(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest) (*dto.Reaction, error) { - ret := _m.Called(ctx, board, body) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)); ok { - return rf(ctx, board, body) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) *dto.Reaction); ok { - r0 = rf(ctx, board, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) error); ok { - r1 = rf(ctx, board, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockReactions_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - body dto.ReactionCreateRequest -func (_e *MockReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockReactions_Create_Call { - return &MockReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} -} - -func (_c *MockReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest)) *MockReactions_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.ReactionCreateRequest)) - }) - return _c -} - -func (_c *MockReactions_Create_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)) *MockReactions_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function with given fields: ctx, board, user, id -func (_m *MockReactions) Delete(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID) error { - ret := _m.Called(ctx, board, user, id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { - r0 = rf(ctx, board, user, id) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockReactions_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type MockReactions_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - user uuid.UUID -// - id uuid.UUID -func (_e *MockReactions_Expecter) Delete(ctx interface{}, board interface{}, user interface{}, id interface{}) *MockReactions_Delete_Call { - return &MockReactions_Delete_Call{Call: _e.mock.On("Delete", ctx, board, user, id)} -} - -func (_c *MockReactions_Delete_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID)) *MockReactions_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) - }) - return _c -} - -func (_c *MockReactions_Delete_Call) Return(_a0 error) *MockReactions_Delete_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockReactions_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockReactions_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockReactions) Get(ctx context.Context, id uuid.UUID) (*dto.Reaction, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Reaction, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Reaction); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockReactions_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockReactions_Expecter) Get(ctx interface{}, id interface{}) *MockReactions_Get_Call { - return &MockReactions_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockReactions_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockReactions_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockReactions_Get_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Reaction, error)) *MockReactions_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function with given fields: ctx, boardID -func (_m *MockReactions) List(ctx context.Context, boardID uuid.UUID) ([]*dto.Reaction, error) { - ret := _m.Called(ctx, boardID) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Reaction, error)); ok { - return rf(ctx, boardID) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Reaction); ok { - r0 = rf(ctx, boardID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, boardID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockReactions_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - boardID uuid.UUID -func (_e *MockReactions_Expecter) List(ctx interface{}, boardID interface{}) *MockReactions_List_Call { - return &MockReactions_List_Call{Call: _e.mock.On("List", ctx, boardID)} -} - -func (_c *MockReactions_List_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockReactions_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockReactions_List_Call) Return(_a0 []*dto.Reaction, _a1 error) *MockReactions_List_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Reaction, error)) *MockReactions_List_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, board, user, id, body -func (_m *MockReactions) Update(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest) (*dto.Reaction, error) { - ret := _m.Called(ctx, board, user, id, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)); ok { - return rf(ctx, board, user, id, body) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) *dto.Reaction); ok { - r0 = rf(ctx, board, user, id, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) error); ok { - r1 = rf(ctx, board, user, id, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockReactions_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - user uuid.UUID -// - id uuid.UUID -// - body dto.ReactionUpdateTypeRequest -func (_e *MockReactions_Expecter) Update(ctx interface{}, board interface{}, user interface{}, id interface{}, body interface{}) *MockReactions_Update_Call { - return &MockReactions_Update_Call{Call: _e.mock.On("Update", ctx, board, user, id, body)} -} - -func (_c *MockReactions_Update_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest)) *MockReactions_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID), args[4].(dto.ReactionUpdateTypeRequest)) - }) - return _c -} - -func (_c *MockReactions_Update_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_Update_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)) *MockReactions_Update_Call { - _c.Call.Return(run) - return _c -} - -// NewMockReactions creates a new instance of MockReactions. 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 NewMockReactions(t interface { - mock.TestingT - Cleanup(func()) -}) *MockReactions { - mock := &MockReactions{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Users.go b/server/src/mocks/services/mock_Users.go deleted file mode 100644 index e5e9855981..0000000000 --- a/server/src/mocks/services/mock_Users.go +++ /dev/null @@ -1,582 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockUsers is an autogenerated mock type for the Users type -type MockUsers struct { - mock.Mock -} - -type MockUsers_Expecter struct { - mock *mock.Mock -} - -func (_m *MockUsers) EXPECT() *MockUsers_Expecter { - return &MockUsers_Expecter{mock: &_m.Mock} -} - -// CreateAppleUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateAppleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateAppleUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateAppleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAppleUser' -type MockUsers_CreateAppleUser_Call struct { - *mock.Call -} - -// CreateAppleUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateAppleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAppleUser_Call { - return &MockUsers_CreateAppleUser_Call{Call: _e.mock.On("CreateAppleUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateAppleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAppleUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateAppleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAppleUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateAppleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAppleUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateAzureAdUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateAzureAdUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateAzureAdUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateAzureAdUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAzureAdUser' -type MockUsers_CreateAzureAdUser_Call struct { - *mock.Call -} - -// CreateAzureAdUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateAzureAdUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAzureAdUser_Call { - return &MockUsers_CreateAzureAdUser_Call{Call: _e.mock.On("CreateAzureAdUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateAzureAdUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAzureAdUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateAzureAdUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAzureAdUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateAzureAdUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAzureAdUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateGitHubUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateGitHubUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateGitHubUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateGitHubUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGitHubUser' -type MockUsers_CreateGitHubUser_Call struct { - *mock.Call -} - -// CreateGitHubUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateGitHubUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGitHubUser_Call { - return &MockUsers_CreateGitHubUser_Call{Call: _e.mock.On("CreateGitHubUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateGitHubUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGitHubUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateGitHubUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGitHubUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateGitHubUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGitHubUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateGoogleUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateGoogleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateGoogleUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateGoogleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGoogleUser' -type MockUsers_CreateGoogleUser_Call struct { - *mock.Call -} - -// CreateGoogleUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateGoogleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGoogleUser_Call { - return &MockUsers_CreateGoogleUser_Call{Call: _e.mock.On("CreateGoogleUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateGoogleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGoogleUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateGoogleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGoogleUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateGoogleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGoogleUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateMicrosoftUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateMicrosoftUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateMicrosoftUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateMicrosoftUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMicrosoftUser' -type MockUsers_CreateMicrosoftUser_Call struct { - *mock.Call -} - -// CreateMicrosoftUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateMicrosoftUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateMicrosoftUser_Call { - return &MockUsers_CreateMicrosoftUser_Call{Call: _e.mock.On("CreateMicrosoftUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateMicrosoftUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateMicrosoftUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateMicrosoftUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateMicrosoftUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateMicrosoftUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateMicrosoftUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateOIDCUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateOIDCUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateOIDCUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateOIDCUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOIDCUser' -type MockUsers_CreateOIDCUser_Call struct { - *mock.Call -} - -// CreateOIDCUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateOIDCUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateOIDCUser_Call { - return &MockUsers_CreateOIDCUser_Call{Call: _e.mock.On("CreateOIDCUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateOIDCUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateOIDCUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateOIDCUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateOIDCUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateOIDCUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateOIDCUser_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockUsers) Get(ctx context.Context, id uuid.UUID) (*dto.User, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.User, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.User); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockUsers_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockUsers_Expecter) Get(ctx interface{}, id interface{}) *MockUsers_Get_Call { - return &MockUsers_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockUsers_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockUsers_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockUsers_Get_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.User, error)) *MockUsers_Get_Call { - _c.Call.Return(run) - return _c -} - -// LoginAnonymous provides a mock function with given fields: ctx, name -func (_m *MockUsers) LoginAnonymous(ctx context.Context, name string) (*dto.User, error) { - ret := _m.Called(ctx, name) - - if len(ret) == 0 { - panic("no return value specified for LoginAnonymous") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*dto.User, error)); ok { - return rf(ctx, name) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *dto.User); ok { - r0 = rf(ctx, name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, name) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_LoginAnonymous_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoginAnonymous' -type MockUsers_LoginAnonymous_Call struct { - *mock.Call -} - -// LoginAnonymous is a helper method to define mock.On call -// - ctx context.Context -// - name string -func (_e *MockUsers_Expecter) LoginAnonymous(ctx interface{}, name interface{}) *MockUsers_LoginAnonymous_Call { - return &MockUsers_LoginAnonymous_Call{Call: _e.mock.On("LoginAnonymous", ctx, name)} -} - -func (_c *MockUsers_LoginAnonymous_Call) Run(run func(ctx context.Context, name string)) *MockUsers_LoginAnonymous_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockUsers_LoginAnonymous_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_LoginAnonymous_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_LoginAnonymous_Call) RunAndReturn(run func(context.Context, string) (*dto.User, error)) *MockUsers_LoginAnonymous_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, body -func (_m *MockUsers) Update(ctx context.Context, body dto.UserUpdateRequest) (*dto.User, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) (*dto.User, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) *dto.User); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.UserUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockUsers_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - body dto.UserUpdateRequest -func (_e *MockUsers_Expecter) Update(ctx interface{}, body interface{}) *MockUsers_Update_Call { - return &MockUsers_Update_Call{Call: _e.mock.On("Update", ctx, body)} -} - -func (_c *MockUsers_Update_Call) Run(run func(ctx context.Context, body dto.UserUpdateRequest)) *MockUsers_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.UserUpdateRequest)) - }) - return _c -} - -func (_c *MockUsers_Update_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_Update_Call) RunAndReturn(run func(context.Context, dto.UserUpdateRequest) (*dto.User, error)) *MockUsers_Update_Call { - _c.Call.Return(run) - return _c -} - -// NewMockUsers creates a new instance of MockUsers. 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 NewMockUsers(t interface { - mock.TestingT - Cleanup(func()) -}) *MockUsers { - mock := &MockUsers{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Votings.go b/server/src/mocks/services/mock_Votings.go deleted file mode 100644 index 0d0a5d69be..0000000000 --- a/server/src/mocks/services/mock_Votings.go +++ /dev/null @@ -1,443 +0,0 @@ -// 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 -} From 7ddeab7f3bbb3941f2c10b61aa46ab8700b558d1 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Thu, 16 Jan 2025 13:38:14 +0100 Subject: [PATCH 08/27] refactor: replace test content structure with TestParameterBundle usage in columns test --- server/src/api/columns_test.go | 156 +++++++++++---------------------- 1 file changed, 50 insertions(+), 106 deletions(-) diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go index cfac8cf8f0..cf4ca46287 100644 --- a/server/src/api/columns_test.go +++ b/server/src/api/columns_test.go @@ -25,28 +25,17 @@ func TestColumnTestSuite(t *testing.T) { } func (suite *ColumnTestSuite) TestCreateColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful created column", - expectedCode: http.StatusCreated, - }, - { - name: "Failed creating column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not create column", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful created column", http.StatusCreated, nil, false, false, nil). + Append("Failed creating column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -89,28 +78,16 @@ func (suite *ColumnTestSuite) TestCreateColumn() { } func (suite *ColumnTestSuite) TestDeleteColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful deleted column", - expectedCode: http.StatusNoContent, - }, - { - name: "Failed deleting column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not delete column", - }, - }, - } - - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful deleted column", http.StatusNoContent, nil, false, false, nil). + Append("Failed deleting column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -136,28 +113,17 @@ func (suite *ColumnTestSuite) TestDeleteColumn() { } func (suite *ColumnTestSuite) TestUpdateColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful updated column", - expectedCode: http.StatusOK, - }, - { - name: "Failed updating column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not update column", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful updated column", http.StatusOK, nil, false, false, nil). + Append("Failed updating column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -201,28 +167,17 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { } func (suite *ColumnTestSuite) TestGetColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful get column", - expectedCode: http.StatusOK, - }, - { - name: "Failed getting column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not get column", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful get column", http.StatusOK, nil, false, false, nil). + Append("Failed getting column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -260,28 +215,17 @@ func (suite *ColumnTestSuite) TestGetColumn() { } func (suite *ColumnTestSuite) TestGetColumns() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful get columns", - expectedCode: http.StatusOK, - }, - { - name: "Failed getting columns", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not get columns", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful get columns", http.StatusOK, nil, false, false, nil). + Append("Failed getting columns", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get columns", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) From 0ea7c49fe9cd955c390416b22580c3a464edf625 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Thu, 16 Jan 2025 13:39:03 +0100 Subject: [PATCH 09/27] refactor: remove commented code --- server/src/api/json_parse_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/src/api/json_parse_test.go b/server/src/api/json_parse_test.go index f93888dd54..5321fbfbe5 100644 --- a/server/src/api/json_parse_test.go +++ b/server/src/api/json_parse_test.go @@ -80,9 +80,6 @@ func (suite *JSONErrTestSuite) TestJSONErrs() { suite.Run(tt.name, func() { s := new(Server) - //loggerConfig := zap.NewNop() // Use a no-op logger for testing - //_logger := loggerConfig.Sugar() - mockUUID := uuid.New() req := NewTestRequestBuilder("POST", "/", strings.NewReader(`{ "id": %s From b24f6dfda6e5ceed5142d26d6824b09e98a4b7ed Mon Sep 17 00:00:00 2001 From: wschoepke Date: Thu, 16 Jan 2025 14:50:49 +0100 Subject: [PATCH 10/27] refactor: refactor notes tests with mockery mocks --- server/src/.mockery.yaml | 2 + server/src/api/notes_test.go | 194 +++--------- server/src/mocks/services/mock_Notes.go | 382 ++++++++++++++++++++++++ 3 files changed, 425 insertions(+), 153 deletions(-) create mode 100644 server/src/mocks/services/mock_Notes.go diff --git a/server/src/.mockery.yaml b/server/src/.mockery.yaml index d8aca0eb11..75bec072d4 100644 --- a/server/src/.mockery.yaml +++ b/server/src/.mockery.yaml @@ -14,3 +14,5 @@ packages: all: true BoardSessions: all: true + Notes: + all: true diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index ff22c04b2d..2916e5c4dd 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -1,7 +1,6 @@ package api import ( - "context" "errors" "fmt" "github.com/go-chi/chi/v5" @@ -12,123 +11,13 @@ import ( "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" ) -type NotesMock struct { - services.Notes - mock.Mock -} - -func (m *NotesMock) Create(ctx context.Context, req dto.NoteCreateRequest) (*dto.Note, error) { - args := m.Called(req) - return args.Get(0).(*dto.Note), args.Error(1) -} -func (m *NotesMock) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { - args := m.Called(id) - return args.Get(0).(*dto.Note), args.Error(1) -} -func (m *NotesMock) Delete(ctx context.Context, req dto.NoteDeleteRequest, id uuid.UUID) error { - args := m.Called(id) - return args.Error(0) - -} - -type BoardsMock struct { - services.Boards - mock.Mock -} - -type SessionsMock struct { - mock.Mock -} - -func (m *SessionsMock) SessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *SessionsMock) ParticipantBanned(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *SessionsMock) Connect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(boardID, userID) - return args.Error(0) -} - -func (m *SessionsMock) Create(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSession), args.Error(1) -} - -// Add other missing methods here -func (m *SessionsMock) Get(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) Update(ctx context.Context, body dto.BoardSessionUpdateRequest) (*dto.BoardSession, error) { - args := m.Called(body) - return args.Get(0).(*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) UpdateAll(ctx context.Context, body dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error) { - args := m.Called(body) - return args.Get(0).([]*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) List(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter) ([]*dto.BoardSession, error) { - args := m.Called(boardID, f) - return args.Get(0).([]*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) Disconnect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(boardID, userID) - return args.Error(0) -} - -func (m *SessionsMock) GetSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) CreateSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) ListSessionRequest(ctx context.Context, boardID uuid.UUID, statusQuery string) ([]*dto.BoardSessionRequest, error) { - args := m.Called(boardID, statusQuery) - return args.Get(0).([]*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) UpdateSessionRequest(ctx context.Context, body dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error) { - args := m.Called(body) - return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) ModeratorSessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *SessionsMock) SessionRequestExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *BoardsMock) Get(ctx context.Context, id uuid.UUID) (*dto.Board, error) { - args := m.Called(id) - return args.Get(0).(*dto.Board), args.Error(1) -} - type NotesTestSuite struct { suite.Suite } @@ -167,38 +56,37 @@ func (suite *NotesTestSuite) TestCreateNote() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(NotesMock) + noteMock := services.NewMockNotes(suite.T()) testText := "asdf" boardId, _ := uuid.NewRandom() userId, _ := uuid.NewRandom() colId, _ := uuid.NewRandom() - mock.On("Create", dto.NoteCreateRequest{ - Board: boardId, - User: userId, - Text: testText, - Column: colId, - }).Return(&dto.Note{ - Text: testText, - }, tt.err) - - s.notes = mock + s.notes = noteMock req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ "column": "%s", "text" : "%s" }`, colId.String(), testText))) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). AddToContext(identifiers.UserIdentifier, userId) + + noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ + Board: boardId, + User: userId, + Text: testText, + Column: colId, + }).Return(&dto.Note{ + Text: testText, + }, tt.err) + rr := httptest.NewRecorder() s.createNote(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + noteMock.AssertExpectations(suite.T()) }) } @@ -233,23 +121,23 @@ func (suite *NotesTestSuite) TestGetNote() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(NotesMock) - s.notes = mock + noteMock := services.NewMockNotes(suite.T()) + s.notes = noteMock noteID, _ := uuid.NewRandom() - mock.On("Get", noteID).Return(&dto.Note{ - ID: noteID, - }, tt.err) - req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.NoteIdentifier, noteID) + noteMock.EXPECT().Get(req.req.Context(), noteID).Return(&dto.Note{ + ID: noteID, + }, tt.err) + rr := httptest.NewRecorder() s.getNote(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + noteMock.AssertExpectations(suite.T()) }) } } @@ -280,49 +168,49 @@ func (suite *NotesTestSuite) TestDeleteNote() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - noteMock := new(NotesMock) + + noteMock := services.NewMockNotes(suite.T()) + boardMock := services.NewMockBoards(suite.T()) + sessionMock := services.NewMockBoardSessions(suite.T()) + s.notes = noteMock - boardMock := new(BoardsMock) s.boards = boardMock - sessionMock := new(SessionsMock) s.sessions = sessionMock boardID, _ := uuid.NewRandom() userID, _ := uuid.NewRandom() noteID, _ := uuid.NewRandom() + r := chi.NewRouter() s.initNoteResources(r) - boardMock.On("Get", boardID).Return(&dto.Board{ + + req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) + req.req = logger.InitTestLoggerRequest(req.Request()) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + req.AddToContext(identifiers.UserIdentifier, userID) + + boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ ID: boardID, IsLocked: tt.isLocked, }, nil) // Mock the SessionExists method - sessionMock.On("SessionExists", boardID, userID).Return(true, nil) + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) // Mock the ModeratorSessionExists method - sessionMock.On("ModeratorSessionExists", boardID, userID).Return(true, nil) + sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) // Mock the ParticipantBanned method - sessionMock.On("ParticipantBanned", boardID, userID).Return(false, nil) + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) if tt.isLocked { - noteMock.On("Delete", mock.Anything, mock.Anything).Return(nil) + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) } else { - boardMock.On("Get", boardID).Return(&dto.Board{ - ID: boardID, - IsLocked: tt.isLocked, - }, tt.err) - noteMock.On("Delete", mock.Anything).Return(tt.err) + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) } - req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) - req.req = logger.InitTestLoggerRequest(req.Request()) - rctx := chi.NewRouteContext() - rctx.URLParams.Add("id", boardID.String()) - req.AddToContext(chi.RouteCtxKey, rctx) - req.AddToContext(identifiers.UserIdentifier, userID) - rr := httptest.NewRecorder() r.ServeHTTP(rr, req.Request()) diff --git a/server/src/mocks/services/mock_Notes.go b/server/src/mocks/services/mock_Notes.go new file mode 100644 index 0000000000..66024de389 --- /dev/null +++ b/server/src/mocks/services/mock_Notes.go @@ -0,0 +1,382 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockNotes is an autogenerated mock type for the Notes type +type MockNotes struct { + mock.Mock +} + +type MockNotes_Expecter struct { + mock *mock.Mock +} + +func (_m *MockNotes) EXPECT() *MockNotes_Expecter { + return &MockNotes_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteCreateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockNotes_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteCreateRequest +func (_e *MockNotes_Expecter) Create(ctx interface{}, body interface{}) *MockNotes_Create_Call { + return &MockNotes_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockNotes_Create_Call) Run(run func(ctx context.Context, body dto.NoteCreateRequest)) *MockNotes_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteCreateRequest)) + }) + return _c +} + +func (_c *MockNotes_Create_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)) *MockNotes_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, body, id +func (_m *MockNotes) Delete(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID) error { + ret := _m.Called(ctx, body, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error); ok { + r0 = rf(ctx, body, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockNotes_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockNotes_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteDeleteRequest +// - id uuid.UUID +func (_e *MockNotes_Expecter) Delete(ctx interface{}, body interface{}, id interface{}) *MockNotes_Delete_Call { + return &MockNotes_Delete_Call{Call: _e.mock.On("Delete", ctx, body, id)} +} + +func (_c *MockNotes_Delete_Call) Run(run func(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID)) *MockNotes_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteDeleteRequest), args[2].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Delete_Call) Return(_a0 error) *MockNotes_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotes_Delete_Call) RunAndReturn(run func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error) *MockNotes_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockNotes_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) Get(ctx interface{}, id interface{}) *MockNotes_Get_Call { + return &MockNotes_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockNotes_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Get_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Note, error)) *MockNotes_Get_Call { + _c.Call.Return(run) + return _c +} + +// Import provides a mock function with given fields: ctx, body +func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Import") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteImportRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Import_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Import' +type MockNotes_Import_Call struct { + *mock.Call +} + +// Import is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteImportRequest +func (_e *MockNotes_Expecter) Import(ctx interface{}, body interface{}) *MockNotes_Import_Call { + return &MockNotes_Import_Call{Call: _e.mock.On("Import", ctx, body)} +} + +func (_c *MockNotes_Import_Call) Run(run func(ctx context.Context, body dto.NoteImportRequest)) *MockNotes_Import_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteImportRequest)) + }) + return _c +} + +func (_c *MockNotes_Import_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Import_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*dto.Note, error)) *MockNotes_Import_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, id +func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockNotes_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) List(ctx interface{}, id interface{}) *MockNotes_List_Call { + return &MockNotes_List_Call{Call: _e.mock.On("List", ctx, id)} +} + +func (_c *MockNotes_List_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_List_Call) Return(_a0 []*dto.Note, _a1 error) *MockNotes_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Note, error)) *MockNotes_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockNotes_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteUpdateRequest +func (_e *MockNotes_Expecter) Update(ctx interface{}, body interface{}) *MockNotes_Update_Call { + return &MockNotes_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockNotes_Update_Call) Run(run func(ctx context.Context, body dto.NoteUpdateRequest)) *MockNotes_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteUpdateRequest)) + }) + return _c +} + +func (_c *MockNotes_Update_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)) *MockNotes_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockNotes creates a new instance of MockNotes. 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 NewMockNotes(t interface { + mock.TestingT + Cleanup(func()) +}) *MockNotes { + mock := &MockNotes{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} From b721a026dbd9f031116d91c8c56d2e25d6d721ca Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 22 Jan 2025 12:13:15 +0100 Subject: [PATCH 11/27] 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 +} From c9f028e9c5a6c2c06bad48913e80410e5d6d8215 Mon Sep 17 00:00:00 2001 From: Mateo Date: Wed, 22 May 2024 10:01:07 +0200 Subject: [PATCH 12/27] basic test cases for api/columns --- server/src/api/columns_test.go | 351 +++++++++++++++++++++++++++++++++ 1 file changed, 351 insertions(+) create mode 100644 server/src/api/columns_test.go diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go new file mode 100644 index 0000000000..27d972566e --- /dev/null +++ b/server/src/api/columns_test.go @@ -0,0 +1,351 @@ +package api + +import ( + "context" + "errors" + "fmt" + "github.com/google/uuid" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/database/types" + "scrumlr.io/server/identifiers" + "scrumlr.io/server/services" + "strings" + "testing" +) + +type BoardMock struct { + services.Boards + mock.Mock +} + +func (m *BoardMock) CreateColumn(ctx context.Context, req dto.ColumnRequest) (*dto.Column, error) { + args := m.Called(req) + return args.Get(0).(*dto.Column), args.Error(1) +} + +func (m *BoardMock) DeleteColumn(ctx context.Context, board, column, user uuid.UUID) error { + args := m.Called(board, column, user) + return args.Error(0) +} + +func (m *BoardMock) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { + args := m.Called(body) + return args.Get(0).(*dto.Column), args.Error(1) +} + +func (m *BoardMock) GetColumn(ctx context.Context, boardID, columnID uuid.UUID) (*dto.Column, error) { + args := m.Called(boardID, columnID) + return args.Get(0).(*dto.Column), args.Error(1) +} + +func (m *BoardMock) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*dto.Column, error) { + args := m.Called(boardID) + return args.Get(0).([]*dto.Column), args.Error(1) +} + +type ColumnTestSuite struct { + suite.Suite +} + +func TestColumnTestSuite(t *testing.T) { + suite.Run(t, new(ColumnTestSuite)) +} + +func (suite *ColumnTestSuite) TestCreateColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful created column", + expectedCode: http.StatusCreated, + }, + { + name: "Failed creating column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + name := "TestColumn" + color := types.Color("backlog-blue") + visible := true + index := 0 + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + + mock.On("CreateColumn", dto.ColumnRequest{ + Name: name, + Color: color, + Visible: &visible, + Index: &index, + Board: boardID, + User: userID, + }).Return(&dto.Column{ + ID: uuid.UUID{}, + Name: name, + Color: color, + Visible: visible, + Index: index, + }, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( + `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, + ))).AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID) + rr := httptest.NewRecorder() + + s.createColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestDeleteColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful deleted column", + expectedCode: http.StatusNoContent, + }, + { + name: "Failed deleting column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + + mock.On("DeleteColumn", boardID, columnID, userID).Return(tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("DEL", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + s.deleteColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestUpdateColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful updated column", + expectedCode: http.StatusOK, + }, + { + name: "Failed updating column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "TestColumn" + color := types.Color("online-orange") + visible := false + index := 0 + + mock.On("UpdateColumn", dto.ColumnUpdateRequest{ + Name: colName, + Color: color, + Visible: visible, + Index: index, + ID: columnID, + Board: boardID, + }).Return(&dto.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + }, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("PUT", "/", strings.NewReader( + fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + s.updateColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestGetColumn() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful get column", + expectedCode: http.StatusOK, + }, + { + name: "Failed getting column", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get column", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "Updated Column Name" + color := types.Color("online-orange") + visible := false + index := 0 + + column := &dto.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + } + + mock.On("GetColumn", boardID, columnID).Return(column, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + s.getColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *ColumnTestSuite) TestGetColumns() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successful get columns", + expectedCode: http.StatusOK, + }, + { + name: "Failed getting columns", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get columns", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "TestColumn" + color := types.Color("online-orange") + visible := false + index := 0 + + column := &dto.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + } + + mock.On("ListColumns", boardID).Return([]*dto.Column{column}, tt.err) + + s.boards = mock + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + rr := httptest.NewRecorder() + + s.getColumns(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} From 5b9e46bf6e31b7cbc5eee37e12934c4f62e3c212 Mon Sep 17 00:00:00 2001 From: Mateo Date: Thu, 23 May 2024 09:10:48 +0200 Subject: [PATCH 13/27] add unit tests for board --- server/src/api/boards.go | 2 +- server/src/api/boards_test.go | 253 ++++++++++++++++++++++++++++++++++ 2 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 server/src/api/boards_test.go diff --git a/server/src/api/boards.go b/server/src/api/boards.go index 20ac5c03f9..b158eb48ba 100644 --- a/server/src/api/boards.go +++ b/server/src/api/boards.go @@ -38,7 +38,7 @@ func (s *Server) createBoard(w http.ResponseWriter, r *http.Request) { b, err := s.boards.Create(r.Context(), body) if err != nil { - common.Throw(w, r, common.BadRequestError(err)) + common.Throw(w, r, err) return } diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go new file mode 100644 index 0000000000..3c747debd7 --- /dev/null +++ b/server/src/api/boards_test.go @@ -0,0 +1,253 @@ +package api + +import ( + "context" + "errors" + "fmt" + "github.com/google/uuid" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/database/types" + "scrumlr.io/server/identifiers" + "strings" + "testing" +) + +func (m *BoardMock) Create(ctx context.Context, req dto.CreateBoardRequest) (*dto.Board, error) { + args := m.Called(req) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) Delete(ctx context.Context, boardID uuid.UUID) error { + args := m.Called(boardID) + return args.Error(0) +} + +func (m *BoardMock) BoardOverview(ctx context.Context, boardIDs []uuid.UUID, userID uuid.UUID) ([]*dto.BoardOverview, error) { + args := m.Called(boardIDs, userID) + return args.Get(0).([]*dto.BoardOverview), args.Error(1) +} + +func (m *BoardMock) Get(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) Update(ctx context.Context, req dto.BoardUpdateRequest) (*dto.Board, error) { + args := m.Called(req) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) SetTimer(ctx context.Context, boardID uuid.UUID, minutes uint8) (*dto.Board, error) { + args := m.Called(boardID, minutes) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) DeleteTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) IncrementTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Error(1) +} + +func (m *BoardMock) FullBoard(ctx context.Context, boardID uuid.UUID) (*dto.Board, []*dto.BoardSessionRequest, []*dto.BoardSession, []*dto.Column, []*dto.Note, []*dto.Reaction, []*dto.Voting, []*dto.Vote, error) { + args := m.Called(boardID) + return args.Get(0).(*dto.Board), args.Get(1).([]*dto.BoardSessionRequest), args.Get(2).([]*dto.BoardSession), args.Get(3).([]*dto.Column), args.Get(4).([]*dto.Note), args.Get(5).([]*dto.Reaction), args.Get(6).([]*dto.Voting), args.Get(7).([]*dto.Vote), args.Error(8) +} + +type BoardTestSuite struct { + suite.Suite +} + +func TestBoardTestSuite(t *testing.T) { + suite.Run(t, new(BoardTestSuite)) +} + +func (suite *BoardTestSuite) TestCreateBoard() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully create board", + expectedCode: http.StatusCreated, + err: nil, + }, + { + name: "Failed creating board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to create board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + accessPolicy := types.AccessPolicyPublic + visible := true + ownerID, _ := uuid.NewRandom() + colName := "Lean Coffee" + color := types.Color("backlog-blue") + boardID, _ := uuid.NewRandom() + + mock.On("Create", dto.CreateBoardRequest{ + Name: nil, + Description: nil, + AccessPolicy: accessPolicy, + Passphrase: nil, + Columns: []dto.ColumnRequest{ + { + Name: colName, + Color: color, + Visible: &visible, + Index: nil, + Board: uuid.Nil, + User: uuid.Nil, + }, + }, + Owner: ownerID, + }).Return(&dto.Board{ + ID: boardID, + Name: nil, + Description: nil, + AccessPolicy: accessPolicy, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, tt.err) + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(` { + "accessPolicy": "%s", + "columns": [ + { + "name": "%s", + "visible": %v, + "color": "%s" + } + ] + }`, accessPolicy, colName, visible, color))). + AddToContext(identifiers.UserIdentifier, ownerID) + + rr := httptest.NewRecorder() + + s.createBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestDeleteBoard() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully deleted board", + expectedCode: http.StatusNoContent, + err: nil, + }, + { + name: "Failed deleting board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to delete board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("Delete", boardID).Return(tt.err) + + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.deleteBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestGetBoards() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully deleted board", + expectedCode: http.StatusNoContent, + err: nil, + }, + { + name: "Failed deleting board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to delete board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("Delete", boardID).Return(tt.err) + + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.deleteBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} From ced8fc7bf743cc1f2f0dfa191c8e3cb16889016d Mon Sep 17 00:00:00 2001 From: Mateo Date: Fri, 24 May 2024 14:26:28 +0200 Subject: [PATCH 14/27] add unit tests for board --- server/src/api/boards_test.go | 550 +++++++++++++++++++++++++++++++++- server/src/api/notes_test.go | 38 +-- 2 files changed, 562 insertions(+), 26 deletions(-) diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go index 3c747debd7..2cf968f92f 100644 --- a/server/src/api/boards_test.go +++ b/server/src/api/boards_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/go-chi/chi/v5" "github.com/google/uuid" "github.com/stretchr/testify/suite" "net/http" @@ -14,6 +15,7 @@ import ( "scrumlr.io/server/identifiers" "strings" "testing" + "time" ) func (m *BoardMock) Create(ctx context.Context, req dto.CreateBoardRequest) (*dto.Board, error) { @@ -36,6 +38,11 @@ func (m *BoardMock) Get(ctx context.Context, boardID uuid.UUID) (*dto.Board, err return args.Get(0).(*dto.Board), args.Error(1) } +func (m *BoardMock) GetBoards(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) { + args := m.Called(userID) + return args.Get(0).([]uuid.UUID), args.Error(1) +} + func (m *BoardMock) Update(ctx context.Context, req dto.BoardUpdateRequest) (*dto.Board, error) { args := m.Called(req) return args.Get(0).(*dto.Board), args.Error(1) @@ -213,18 +220,120 @@ func (suite *BoardTestSuite) TestGetBoards() { err error }{ { - name: "Successfully deleted board", - expectedCode: http.StatusNoContent, + name: "Successfully received boards", + expectedCode: http.StatusOK, err: nil, }, { - name: "Failed deleting board", + name: "Failed receiving boards", expectedCode: http.StatusInternalServerError, err: &common.APIError{ - Err: errors.New("failed to delete board"), + Err: errors.New("failed to receive boards"), StatusCode: http.StatusInternalServerError, StatusText: "no", - ErrorText: "Could not delete board", + ErrorText: "Could not receive boards", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + userID, _ := uuid.NewRandom() + + boardName := "Test Name" + boardDescription := "Test Description" + firstBoard := &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: "", + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + } + + boardName = "Test Board" + boardDescription = "Description for second board" + secondBoard := &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: "", + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + } + boardIDs := []uuid.UUID{firstBoard.ID, secondBoard.ID} + + mock.On("GetBoards", userID).Return(boardIDs, tt.err) + if tt.err == nil { + mock.On("BoardOverview", boardIDs, userID).Return([]*dto.BoardOverview{{ + Board: firstBoard, + Columns: 1, + CreatedAt: time.Time{}, + Participants: 3, + }, + { + Board: secondBoard, + Columns: 2, + CreatedAt: time.Time{}, + Participants: 4, + }, + }, tt.err) + } + + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.UserIdentifier, userID) + + rr := httptest.NewRecorder() + + s.getBoards(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestGetBoard() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully received boards", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed receiving boards", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to receive boards"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not receive boards", }, }, } @@ -237,14 +346,441 @@ func (suite *BoardTestSuite) TestGetBoards() { boardID, _ := uuid.NewRandom() - mock.On("Delete", boardID).Return(tt.err) + boardName := "Test Name" + boardDescription := "Test Description" + board := &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: "", + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + } + + mock.On("Get", boardID).Return(board, tt.err) req := NewTestRequestBuilder("POST", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) rr := httptest.NewRecorder() - s.deleteBoard(rr, req.Request()) + s.getBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestJoinBoard() { + boardName := "Test Name" + boardDescription := "Test Description" + salt := "z9YcpBno6azI2ueA" + passphrase := common.Sha512BySalt("123", salt) + + tests := []struct { + name string + expectedCode int + err error + sessionExists bool + sessionRequestExists bool + board *dto.Board + }{ + { + name: "Successfully join board", + expectedCode: http.StatusSeeOther, + err: nil, + sessionExists: true, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyPublic, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, + }, + { + name: "Failed joining board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to join board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not join board", + }, + sessionExists: true, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyPublic, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, + }, + { + name: "Successfully joined board without session", + expectedCode: http.StatusCreated, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyPublic, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: nil, + Salt: nil, + }, + }, { + name: "Successfully joined board with passphrase", + expectedCode: http.StatusCreated, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyByPassphrase, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: &passphrase, + Salt: &salt, + }, + }, + { + name: "Successfully join board by invite with existing session request", + expectedCode: http.StatusSeeOther, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyByInvite, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: &passphrase, + Salt: &salt, + }, + sessionRequestExists: true, + }, + { + name: "Successfully join board by invite with existing session request", + expectedCode: http.StatusSeeOther, + err: nil, + sessionExists: false, + board: &dto.Board{ + ID: uuid.New(), + Name: &boardName, + Description: &boardDescription, + AccessPolicy: types.AccessPolicyByInvite, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + AllowEditing: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: &passphrase, + Salt: &salt, + }, + sessionRequestExists: false, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + sessionMock := new(SessionsMock) + s.boards = mock + s.sessions = sessionMock + + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + sessionMock.On("SessionExists", boardID, userID).Return(tt.sessionExists, nil) + if tt.sessionExists { + sessionMock.On("ParticipantBanned", boardID, userID).Return(false, tt.err) + } else { + //sessionMock.On("SessionExists", boardID, userID).Return(false, nil) + mock.On("Get", boardID).Return(tt.board, tt.err) + } + + if tt.board.AccessPolicy == types.AccessPolicyByInvite { + sessionMock.On("SessionRequestExists", boardID, userID).Return(tt.sessionRequestExists, tt.err) + if !tt.sessionRequestExists { + sessionMock.On("CreateSessionRequest", boardID, userID).Return(new(dto.BoardSessionRequest), tt.err) + } + } else { + if !tt.sessionExists { + sessionMock.On("Create", boardID, userID).Return(new(dto.BoardSession), tt.err) + } + + } + + req := NewTestRequestBuilder("POST", fmt.Sprintf("/%s", boardID), strings.NewReader(`{"passphrase": "123"}`)). + AddToContext(identifiers.UserIdentifier, userID) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + + rr := httptest.NewRecorder() + + s.joinBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + sessionMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestUpdateBoards() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully updated boards", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed updating board", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to update board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update board", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + newName := "UpdatedName" + newDescription := "UpdatedDescription" + boardID, _ := uuid.NewRandom() + accessPolicy := types.AccessPolicyPublic + boardReq := dto.BoardUpdateRequest{ + Name: &newName, + Description: &newDescription, + AccessPolicy: &accessPolicy, + ID: boardID, + } + + mock.On("Update", boardReq).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("PUT", fmt.Sprintf("/%s", boardID), strings.NewReader(fmt.Sprintf(`{ + "id": "%s", + "name": "%s", + "description": "%s", + "accessPolicy": "PUBLIC" + }`, boardID, newName, newDescription))). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.updateBoard(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestSetTimer() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully set timer", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed set timer", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to set timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not set timer", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + minutes := uint8(4) + + mock.On("SetTimer", boardID, minutes).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("PUT", "/timer", strings.NewReader(fmt.Sprintf(`{"minutes": %d}`, minutes))). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.setTimer(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestDeleteTimer() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully deleted timer", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed deleting timer", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to delete timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete timer", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("DeleteTimer", boardID).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("DEL", "/timer", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.deleteTimer(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + mock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestIncrementTimer() { + tests := []struct { + name string + expectedCode int + err error + }{ + { + name: "Successfully increment timer", + expectedCode: http.StatusOK, + err: nil, + }, + { + name: "Failed incrementing timer", + expectedCode: http.StatusInternalServerError, + err: &common.APIError{ + Err: errors.New("failed to increment timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not increment timer", + }, + }, + } + + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + mock := new(BoardMock) + s.boards = mock + + boardID, _ := uuid.NewRandom() + + mock.On("IncrementTimer", boardID).Return(new(dto.Board), tt.err) + + req := NewTestRequestBuilder("POST", "/timer/increment", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + + rr := httptest.NewRecorder() + + s.incrementTimer(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) mock.AssertExpectations(suite.T()) diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index a3aec58101..8f371fb880 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -50,78 +50,78 @@ type SessionsMock struct { } func (m *SessionsMock) SessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } func (m *SessionsMock) ParticipantBanned(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } func (m *SessionsMock) Connect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Error(0) } func (m *SessionsMock) Create(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSession), args.Error(1) } // Add other missing methods here func (m *SessionsMock) Get(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSession), args.Error(1) } func (m *SessionsMock) Update(ctx context.Context, body dto.BoardSessionUpdateRequest) (*dto.BoardSession, error) { - args := m.Called(ctx, body) + args := m.Called(body) return args.Get(0).(*dto.BoardSession), args.Error(1) } func (m *SessionsMock) UpdateAll(ctx context.Context, body dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error) { - args := m.Called(ctx, body) + args := m.Called(body) return args.Get(0).([]*dto.BoardSession), args.Error(1) } func (m *SessionsMock) List(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter) ([]*dto.BoardSession, error) { - args := m.Called(ctx, boardID, f) + args := m.Called(boardID, f) return args.Get(0).([]*dto.BoardSession), args.Error(1) } func (m *SessionsMock) Disconnect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Error(0) } func (m *SessionsMock) GetSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) CreateSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) ListSessionRequest(ctx context.Context, boardID uuid.UUID, statusQuery string) ([]*dto.BoardSessionRequest, error) { - args := m.Called(ctx, boardID, statusQuery) + args := m.Called(boardID, statusQuery) return args.Get(0).([]*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) UpdateSessionRequest(ctx context.Context, body dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error) { - args := m.Called(ctx, body) + args := m.Called(body) return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) } func (m *SessionsMock) ModeratorSessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } func (m *SessionsMock) SessionRequestExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(ctx, boardID, userID) + args := m.Called(boardID, userID) return args.Bool(0), args.Error(1) } @@ -299,13 +299,13 @@ func (suite *NotesTestSuite) TestDeleteNote() { }, nil) // Mock the SessionExists method - sessionMock.On("SessionExists", mock.Anything, boardID, userID).Return(true, nil) + sessionMock.On("SessionExists", boardID, userID).Return(true, nil) // Mock the ModeratorSessionExists method - sessionMock.On("ModeratorSessionExists", mock.Anything, boardID, userID).Return(true, nil) + sessionMock.On("ModeratorSessionExists", boardID, userID).Return(true, nil) // Mock the ParticipantBanned method - sessionMock.On("ParticipantBanned", mock.Anything, boardID, userID).Return(false, nil) + sessionMock.On("ParticipantBanned", boardID, userID).Return(false, nil) if tt.isLocked { noteMock.On("Delete", mock.Anything, mock.Anything).Return(nil) @@ -314,7 +314,7 @@ func (suite *NotesTestSuite) TestDeleteNote() { ID: boardID, IsLocked: tt.isLocked, }, tt.err) - noteMock.On("Delete", mock.Anything, mock.Anything).Return(tt.err) + noteMock.On("Delete", mock.Anything).Return(tt.err) } req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) From 92af42ab2d2b6c9ad756307bb94081e7d555fa7e Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 11:32:33 +0100 Subject: [PATCH 15/27] add unit tests for board --- server/src/api/boards_test.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go index 2cf968f92f..cc889e4ae8 100644 --- a/server/src/api/boards_test.go +++ b/server/src/api/boards_test.go @@ -136,7 +136,7 @@ func (suite *BoardTestSuite) TestCreateBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -255,7 +255,7 @@ func (suite *BoardTestSuite) TestGetBoards() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -275,7 +275,7 @@ func (suite *BoardTestSuite) TestGetBoards() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -357,7 +357,7 @@ func (suite *BoardTestSuite) TestGetBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -409,7 +409,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -437,7 +437,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -460,7 +460,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -482,7 +482,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -505,7 +505,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, @@ -529,7 +529,7 @@ func (suite *BoardTestSuite) TestJoinBoard() { ShowNotesOfOtherUsers: true, ShowNoteReactions: true, AllowStacking: true, - AllowEditing: true, + IsLocked: true, TimerStart: nil, TimerEnd: nil, SharedNote: uuid.NullUUID{}, From 73eb8ebcf2844eeba6774354eea351b64899dd06 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 15:59:31 +0100 Subject: [PATCH 16/27] chore: The first steps for the transition to mockery in the API layer have been completed. Next, we still need to implement mockery in all API tests and delete the manual interfaces steps to todo: * remove old manual written interface mock implementation, * adapt api tests, * enhance readme for mockery setup. --- server/src/.mockery.yaml | 13 + server/src/api/boards_test.go | 771 +++++++------------------ server/src/api/columns_test.go | 108 ++-- server/src/api/request_builder.go | 1 - server/src/api/test_content_builder.go | 81 +++ 5 files changed, 348 insertions(+), 626 deletions(-) create mode 100644 server/src/.mockery.yaml create mode 100644 server/src/api/test_content_builder.go diff --git a/server/src/.mockery.yaml b/server/src/.mockery.yaml new file mode 100644 index 0000000000..c26a0bf520 --- /dev/null +++ b/server/src/.mockery.yaml @@ -0,0 +1,13 @@ +with-expecter: true +dir: mocks/{{ replaceAll .InterfaceDirRelative "internal" "internal_" }} +mockname: "Mock{{.InterfaceName}}" +outpkg: "{{.PackageName}}" +filename: "mock_{{.InterfaceName}}.go" +resolve-type-alias: false +issue-845-fix: true +packages: + # configuration on package level + scrumlr.io/server/services: + config: + # generate for all interfaces in services a mock (for example: mock_Boards) + all: true diff --git a/server/src/api/boards_test.go b/server/src/api/boards_test.go index cc889e4ae8..69da450fa5 100644 --- a/server/src/api/boards_test.go +++ b/server/src/api/boards_test.go @@ -1,7 +1,6 @@ package api import ( - "context" "errors" "fmt" "github.com/go-chi/chi/v5" @@ -13,61 +12,12 @@ import ( "scrumlr.io/server/common/dto" "scrumlr.io/server/database/types" "scrumlr.io/server/identifiers" + "scrumlr.io/server/mocks/services" "strings" "testing" "time" ) -func (m *BoardMock) Create(ctx context.Context, req dto.CreateBoardRequest) (*dto.Board, error) { - args := m.Called(req) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) Delete(ctx context.Context, boardID uuid.UUID) error { - args := m.Called(boardID) - return args.Error(0) -} - -func (m *BoardMock) BoardOverview(ctx context.Context, boardIDs []uuid.UUID, userID uuid.UUID) ([]*dto.BoardOverview, error) { - args := m.Called(boardIDs, userID) - return args.Get(0).([]*dto.BoardOverview), args.Error(1) -} - -func (m *BoardMock) Get(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) GetBoards(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) { - args := m.Called(userID) - return args.Get(0).([]uuid.UUID), args.Error(1) -} - -func (m *BoardMock) Update(ctx context.Context, req dto.BoardUpdateRequest) (*dto.Board, error) { - args := m.Called(req) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) SetTimer(ctx context.Context, boardID uuid.UUID, minutes uint8) (*dto.Board, error) { - args := m.Called(boardID, minutes) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) DeleteTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) IncrementTimer(ctx context.Context, boardID uuid.UUID) (*dto.Board, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Error(1) -} - -func (m *BoardMock) FullBoard(ctx context.Context, boardID uuid.UUID) (*dto.Board, []*dto.BoardSessionRequest, []*dto.BoardSession, []*dto.Column, []*dto.Note, []*dto.Reaction, []*dto.Voting, []*dto.Vote, error) { - args := m.Called(boardID) - return args.Get(0).(*dto.Board), args.Get(1).([]*dto.BoardSessionRequest), args.Get(2).([]*dto.BoardSession), args.Get(3).([]*dto.Column), args.Get(4).([]*dto.Note), args.Get(5).([]*dto.Reaction), args.Get(6).([]*dto.Voting), args.Get(7).([]*dto.Vote), args.Error(8) -} - type BoardTestSuite struct { suite.Suite } @@ -76,42 +26,62 @@ func TestBoardTestSuite(t *testing.T) { suite.Run(t, new(BoardTestSuite)) } -func (suite *BoardTestSuite) TestCreateBoard() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully create board", - expectedCode: http.StatusCreated, - err: nil, - }, - { - name: "Failed creating board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to create board"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not create board", - }, - }, +func (suite *BoardTestSuite) createBoard(boardName *string, boardDescription *string, accessPolicy types.AccessPolicy, passphrase *string, salt *string) *dto.Board { + return &dto.Board{ + ID: uuid.New(), + Name: boardName, + Description: boardDescription, + AccessPolicy: accessPolicy, + ShowAuthors: true, + ShowNotesOfOtherUsers: true, + ShowNoteReactions: true, + AllowStacking: true, + IsLocked: true, + TimerStart: nil, + TimerEnd: nil, + SharedNote: uuid.NullUUID{}, + ShowVoting: uuid.NullUUID{}, + Passphrase: passphrase, + Salt: salt, } +} - for _, tt := range tests { - suite.Run(tt.name, func() { +func (suite *BoardTestSuite) TestCreateBoard() { + + testParameterBundles := *TestParameterBundles{}. + Append("Successfully create board", http.StatusCreated, nil, false, false, nil). + Append("Failed creating board", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to create board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create board", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock + boardMock := services.NewMockBoards(suite.T()) + + s.boards = boardMock accessPolicy := types.AccessPolicyPublic visible := true - ownerID, _ := uuid.NewRandom() colName := "Lean Coffee" color := types.Color("backlog-blue") - boardID, _ := uuid.NewRandom() + ownerID := uuid.New() - mock.On("Create", dto.CreateBoardRequest{ + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(` { + "accessPolicy": "%s", + "columns": [ + { + "name": "%s", + "visible": %v, + "color": "%s" + } + ] + }`, accessPolicy, colName, visible, color))). + AddToContext(identifiers.UserIdentifier, ownerID) + + boardMock.EXPECT().Create(req.req.Context(), dto.CreateBoardRequest{ Name: nil, Description: nil, AccessPolicy: accessPolicy, @@ -127,167 +97,83 @@ func (suite *BoardTestSuite) TestCreateBoard() { }, }, Owner: ownerID, - }).Return(&dto.Board{ - ID: boardID, - Name: nil, - Description: nil, - AccessPolicy: accessPolicy, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, tt.err) - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(` { - "accessPolicy": "%s", - "columns": [ - { - "name": "%s", - "visible": %v, - "color": "%s" - } - ] - }`, accessPolicy, colName, visible, color))). - AddToContext(identifiers.UserIdentifier, ownerID) + }).Return(suite.createBoard(nil, nil, accessPolicy, nil, nil), te.err) rr := httptest.NewRecorder() s.createBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestDeleteBoard() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully deleted board", - expectedCode: http.StatusNoContent, - err: nil, - }, - { - name: "Failed deleting board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to delete board"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not delete board", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully deleted board", http.StatusNoContent, nil, false, false, nil). + Append("Failed deleting board", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to delete board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete board", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() - - mock.On("Delete", boardID).Return(tt.err) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() req := NewTestRequestBuilder("POST", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().Delete(req.req.Context(), boardID).Return(te.err) rr := httptest.NewRecorder() s.deleteBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestGetBoards() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully received boards", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed receiving boards", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to receive boards"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not receive boards", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully received boards", http.StatusOK, nil, false, false, nil). + Append("Failed receiving boards", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to receive boards"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not receive boards", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - userID, _ := uuid.NewRandom() + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + userID := uuid.New() boardName := "Test Name" boardDescription := "Test Description" - firstBoard := &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: "", - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - } + firstBoard := suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil) boardName = "Test Board" boardDescription = "Description for second board" - secondBoard := &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: "", - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - } + secondBoard := suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil) boardIDs := []uuid.UUID{firstBoard.ID, secondBoard.ID} - mock.On("GetBoards", userID).Return(boardIDs, tt.err) - if tt.err == nil { - mock.On("BoardOverview", boardIDs, userID).Return([]*dto.BoardOverview{{ + req := NewTestRequestBuilder("POST", "/", nil). + AddToContext(identifiers.UserIdentifier, userID) + + boardMock.EXPECT().GetBoards(req.req.Context(), userID).Return(boardIDs, te.err) + if te.err == nil { + boardMock.EXPECT().BoardOverview(req.req.Context(), boardIDs, userID).Return([]*dto.BoardOverview{{ Board: firstBoard, Columns: 1, CreatedAt: time.Time{}, @@ -299,84 +185,52 @@ func (suite *BoardTestSuite) TestGetBoards() { CreatedAt: time.Time{}, Participants: 4, }, - }, tt.err) + }, te.err) } - req := NewTestRequestBuilder("POST", "/", nil). - AddToContext(identifiers.UserIdentifier, userID) - rr := httptest.NewRecorder() s.getBoards(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestGetBoard() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully received boards", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed receiving boards", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to receive boards"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not receive boards", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully received boards", http.StatusOK, nil, false, false, nil). + Append("Failed receiving boards", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to receive boards"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not receive boards", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() boardName := "Test Name" boardDescription := "Test Description" - board := &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: "", - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - } - - mock.On("Get", boardID).Return(board, tt.err) + board := suite.createBoard(&boardName, &boardDescription, "", nil, nil) req := NewTestRequestBuilder("POST", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().Get(req.req.Context(), boardID).Return(board, te.err) + rr := httptest.NewRecorder() s.getBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } @@ -387,239 +241,87 @@ func (suite *BoardTestSuite) TestJoinBoard() { salt := "z9YcpBno6azI2ueA" passphrase := common.Sha512BySalt("123", salt) - tests := []struct { - name string - expectedCode int - err error - sessionExists bool - sessionRequestExists bool - board *dto.Board - }{ - { - name: "Successfully join board", - expectedCode: http.StatusSeeOther, - err: nil, - sessionExists: true, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyPublic, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, - }, - { - name: "Failed joining board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ + testParameterBundles := *TestParameterBundles{}. + Append("Successfully join board", http.StatusSeeOther, nil, true, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil)). + Append("Failed joining board", http.StatusInternalServerError, + &common.APIError{ Err: errors.New("failed to join board"), StatusCode: http.StatusInternalServerError, StatusText: "no", ErrorText: "Could not join board", - }, - sessionExists: true, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyPublic, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, - }, - { - name: "Successfully joined board without session", - expectedCode: http.StatusCreated, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyPublic, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: nil, - Salt: nil, - }, - }, { - name: "Successfully joined board with passphrase", - expectedCode: http.StatusCreated, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyByPassphrase, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: &passphrase, - Salt: &salt, - }, - }, - { - name: "Successfully join board by invite with existing session request", - expectedCode: http.StatusSeeOther, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyByInvite, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: &passphrase, - Salt: &salt, - }, - sessionRequestExists: true, - }, - { - name: "Successfully join board by invite with existing session request", - expectedCode: http.StatusSeeOther, - err: nil, - sessionExists: false, - board: &dto.Board{ - ID: uuid.New(), - Name: &boardName, - Description: &boardDescription, - AccessPolicy: types.AccessPolicyByInvite, - ShowAuthors: true, - ShowNotesOfOtherUsers: true, - ShowNoteReactions: true, - AllowStacking: true, - IsLocked: true, - TimerStart: nil, - TimerEnd: nil, - SharedNote: uuid.NullUUID{}, - ShowVoting: uuid.NullUUID{}, - Passphrase: &passphrase, - Salt: &salt, - }, - sessionRequestExists: false, - }, - } - - for _, tt := range tests { - suite.Run(tt.name, func() { + }, true, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil)). + Append("Successfully joined board without session", http.StatusCreated, nil, false, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil)). + Append("Successfully joined board with passphrase", http.StatusCreated, nil, false, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyByPassphrase, &passphrase, &salt)). + Append("Successfully join board by invite with existing session request", http.StatusSeeOther, nil, false, true, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyByInvite, &passphrase, &salt)). + Append("Successfully join board by invite with existing session request", http.StatusSeeOther, nil, false, false, suite.createBoard(&boardName, &boardDescription, types.AccessPolicyByInvite, &passphrase, &salt)) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - sessionMock := new(SessionsMock) - s.boards = mock + boardMock := services.NewMockBoards(suite.T()) + sessionMock := services.NewMockBoardSessions(suite.T()) + s.boards = boardMock s.sessions = sessionMock + boardID := uuid.New() + userID := uuid.New() + + req := NewTestRequestBuilder("POST", fmt.Sprintf("/%s", boardID), strings.NewReader(`{"passphrase": "123"}`)). + AddToContext(identifiers.UserIdentifier, userID) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(te.sessionExists, nil) - boardID, _ := uuid.NewRandom() - userID, _ := uuid.NewRandom() - sessionMock.On("SessionExists", boardID, userID).Return(tt.sessionExists, nil) - if tt.sessionExists { - sessionMock.On("ParticipantBanned", boardID, userID).Return(false, tt.err) + if te.sessionExists { + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, te.err) } else { - //sessionMock.On("SessionExists", boardID, userID).Return(false, nil) - mock.On("Get", boardID).Return(tt.board, tt.err) + boardMock.EXPECT().Get(req.req.Context(), boardID).Return(te.board, te.err) } - if tt.board.AccessPolicy == types.AccessPolicyByInvite { - sessionMock.On("SessionRequestExists", boardID, userID).Return(tt.sessionRequestExists, tt.err) - if !tt.sessionRequestExists { - sessionMock.On("CreateSessionRequest", boardID, userID).Return(new(dto.BoardSessionRequest), tt.err) + if te.board.AccessPolicy == types.AccessPolicyByInvite { + sessionMock.EXPECT().SessionRequestExists(req.req.Context(), boardID, userID).Return(te.sessionRequestExists, te.err) + if !te.sessionRequestExists { + sessionMock.EXPECT().CreateSessionRequest(req.req.Context(), boardID, userID).Return(new(dto.BoardSessionRequest), te.err) } } else { - if !tt.sessionExists { - sessionMock.On("Create", boardID, userID).Return(new(dto.BoardSession), tt.err) + if !te.sessionExists { + sessionMock.EXPECT().Create(req.req.Context(), boardID, userID).Return(new(dto.BoardSession), te.err) } } - req := NewTestRequestBuilder("POST", fmt.Sprintf("/%s", boardID), strings.NewReader(`{"passphrase": "123"}`)). - AddToContext(identifiers.UserIdentifier, userID) - rctx := chi.NewRouteContext() - rctx.URLParams.Add("id", boardID.String()) - req.AddToContext(chi.RouteCtxKey, rctx) - rr := httptest.NewRecorder() s.joinBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) sessionMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestUpdateBoards() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully updated boards", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed updating board", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to update board"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not update board", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully updated boards", http.StatusOK, nil, false, false, nil). + Append("Failed updating board", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to update board"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update board", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() newName := "UpdatedName" newDescription := "UpdatedDescription" - boardID, _ := uuid.NewRandom() accessPolicy := types.AccessPolicyPublic boardReq := dto.BoardUpdateRequest{ Name: &newName, @@ -628,8 +330,6 @@ func (suite *BoardTestSuite) TestUpdateBoards() { ID: boardID, } - mock.On("Update", boardReq).Return(new(dto.Board), tt.err) - req := NewTestRequestBuilder("PUT", fmt.Sprintf("/%s", boardID), strings.NewReader(fmt.Sprintf(`{ "id": "%s", "name": "%s", @@ -638,152 +338,115 @@ func (suite *BoardTestSuite) TestUpdateBoards() { }`, boardID, newName, newDescription))). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().Update(req.req.Context(), boardReq).Return(new(dto.Board), te.err) + rr := httptest.NewRecorder() s.updateBoard(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestSetTimer() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully set timer", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed set timer", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to set timer"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not set timer", - }, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully set timer", http.StatusOK, nil, false, false, nil). + Append("Failed set timer", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to set timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not set timer", + }, false, false, nil) + + for _, te := range testParameterBundles { + suite.Run(te.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() minutes := uint8(4) - mock.On("SetTimer", boardID, minutes).Return(new(dto.Board), tt.err) - req := NewTestRequestBuilder("PUT", "/timer", strings.NewReader(fmt.Sprintf(`{"minutes": %d}`, minutes))). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().SetTimer(req.req.Context(), boardID, minutes).Return(new(dto.Board), te.err) + rr := httptest.NewRecorder() s.setTimer(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestDeleteTimer() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully deleted timer", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed deleting timer", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to delete timer"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not delete timer", - }, - }, - } - for _, tt := range tests { + testParameterBundles := TestParameterBundles{}. + Append("Successfully deleted timer", http.StatusOK, nil, false, false, nil). + Append("Failed deleting timer", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to delete timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete timer", + }, false, false, nil) + + for _, tt := range *testParameterBundles { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() - - mock.On("DeleteTimer", boardID).Return(new(dto.Board), tt.err) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() req := NewTestRequestBuilder("DEL", "/timer", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().DeleteTimer(req.req.Context(), boardID).Return(new(dto.Board), tt.err) + rr := httptest.NewRecorder() s.deleteTimer(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } func (suite *BoardTestSuite) TestIncrementTimer() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successfully increment timer", - expectedCode: http.StatusOK, - err: nil, - }, - { - name: "Failed incrementing timer", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New("failed to increment timer"), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not increment timer", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successfully increment timer", http.StatusOK, nil, false, false, nil). + Append("Failed incrementing timer", http.StatusInternalServerError, &common.APIError{ + Err: errors.New("failed to increment timer"), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not increment timer", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) - s.boards = mock - - boardID, _ := uuid.NewRandom() - - mock.On("IncrementTimer", boardID).Return(new(dto.Board), tt.err) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() req := NewTestRequestBuilder("POST", "/timer/increment", nil). AddToContext(identifiers.BoardIdentifier, boardID) + boardMock.EXPECT().IncrementTimer(req.req.Context(), boardID).Return(new(dto.Board), tt.err) + rr := httptest.NewRecorder() s.incrementTimer(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go index 27d972566e..cfac8cf8f0 100644 --- a/server/src/api/columns_test.go +++ b/server/src/api/columns_test.go @@ -1,11 +1,9 @@ package api import ( - "context" "errors" "fmt" "github.com/google/uuid" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" "net/http" "net/http/httptest" @@ -13,41 +11,11 @@ import ( "scrumlr.io/server/common/dto" "scrumlr.io/server/database/types" "scrumlr.io/server/identifiers" - "scrumlr.io/server/services" + "scrumlr.io/server/mocks/services" "strings" "testing" ) -type BoardMock struct { - services.Boards - mock.Mock -} - -func (m *BoardMock) CreateColumn(ctx context.Context, req dto.ColumnRequest) (*dto.Column, error) { - args := m.Called(req) - return args.Get(0).(*dto.Column), args.Error(1) -} - -func (m *BoardMock) DeleteColumn(ctx context.Context, board, column, user uuid.UUID) error { - args := m.Called(board, column, user) - return args.Error(0) -} - -func (m *BoardMock) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { - args := m.Called(body) - return args.Get(0).(*dto.Column), args.Error(1) -} - -func (m *BoardMock) GetColumn(ctx context.Context, boardID, columnID uuid.UUID) (*dto.Column, error) { - args := m.Called(boardID, columnID) - return args.Get(0).(*dto.Column), args.Error(1) -} - -func (m *BoardMock) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*dto.Column, error) { - args := m.Called(boardID) - return args.Get(0).([]*dto.Column), args.Error(1) -} - type ColumnTestSuite struct { suite.Suite } @@ -81,7 +49,7 @@ func (suite *ColumnTestSuite) TestCreateColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) name := "TestColumn" color := types.Color("backlog-blue") visible := true @@ -89,7 +57,13 @@ func (suite *ColumnTestSuite) TestCreateColumn() { boardID, _ := uuid.NewRandom() userID, _ := uuid.NewRandom() - mock.On("CreateColumn", dto.ColumnRequest{ + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( + `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, + ))).AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().CreateColumn(req.req.Context(), dto.ColumnRequest{ Name: name, Color: color, Visible: &visible, @@ -104,18 +78,12 @@ func (suite *ColumnTestSuite) TestCreateColumn() { Index: index, }, tt.err) - s.boards = mock - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( - `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, - ))).AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.UserIdentifier, userID) - rr := httptest.NewRecorder() + s.boards = boardMock s.createColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -145,25 +113,24 @@ func (suite *ColumnTestSuite) TestDeleteColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() userID, _ := uuid.NewRandom() - mock.On("DeleteColumn", boardID, columnID, userID).Return(tt.err) - - s.boards = mock - req := NewTestRequestBuilder("DEL", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID). AddToContext(identifiers.UserIdentifier, userID). AddToContext(identifiers.ColumnIdentifier, columnID) rr := httptest.NewRecorder() + boardMock.EXPECT().DeleteColumn(req.req.Context(), boardID, columnID, userID).Return(tt.err) + + s.boards = boardMock s.deleteColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -193,7 +160,7 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() @@ -202,7 +169,13 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { visible := false index := 0 - mock.On("UpdateColumn", dto.ColumnUpdateRequest{ + req := NewTestRequestBuilder("PUT", "/", strings.NewReader( + fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().UpdateColumn(req.req.Context(), dto.ColumnUpdateRequest{ Name: colName, Color: color, Visible: visible, @@ -217,18 +190,12 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { Index: index, }, tt.err) - s.boards = mock - - req := NewTestRequestBuilder("PUT", "/", strings.NewReader( - fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). - AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.ColumnIdentifier, columnID) - rr := httptest.NewRecorder() + s.boards = boardMock s.updateColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -258,7 +225,7 @@ func (suite *ColumnTestSuite) TestGetColumn() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() @@ -275,19 +242,19 @@ func (suite *ColumnTestSuite) TestGetColumn() { Index: index, } - mock.On("GetColumn", boardID, columnID).Return(column, tt.err) - - s.boards = mock - req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID). AddToContext(identifiers.ColumnIdentifier, columnID) rr := httptest.NewRecorder() + boardMock.EXPECT().GetColumn(req.req.Context(), boardID, columnID).Return(column, tt.err) + + s.boards = boardMock + s.getColumn(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } @@ -317,7 +284,7 @@ func (suite *ColumnTestSuite) TestGetColumns() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(BoardMock) + boardMock := services.NewMockBoards(suite.T()) boardID, _ := uuid.NewRandom() columnID, _ := uuid.NewRandom() @@ -334,18 +301,17 @@ func (suite *ColumnTestSuite) TestGetColumns() { Index: index, } - mock.On("ListColumns", boardID).Return([]*dto.Column{column}, tt.err) - - s.boards = mock - req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.BoardIdentifier, boardID) rr := httptest.NewRecorder() + boardMock.EXPECT().ListColumns(req.req.Context(), boardID).Return([]*dto.Column{column}, tt.err) + + s.boards = boardMock s.getColumns(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) }) } } diff --git a/server/src/api/request_builder.go b/server/src/api/request_builder.go index d20f2c5be4..9772fbb5cd 100644 --- a/server/src/api/request_builder.go +++ b/server/src/api/request_builder.go @@ -27,5 +27,4 @@ func (b *TestRequestBuilder) AddToContext(key, val interface{}) *TestRequestBuil func (b *TestRequestBuilder) Request() *http.Request { return b.req.Clone(b.req.Context()) - } diff --git a/server/src/api/test_content_builder.go b/server/src/api/test_content_builder.go new file mode 100644 index 0000000000..913f2be7f3 --- /dev/null +++ b/server/src/api/test_content_builder.go @@ -0,0 +1,81 @@ +package api + +import "scrumlr.io/server/common/dto" + +type TestParameterBundle struct { + name string + expectedCode int + err error + sessionExists bool + sessionRequestExists bool + board *dto.Board +} + +type TestParameterBundleBuilder struct { + name string + expectedCode int + err error + sessionExists bool + sessionRequestExists bool + board *dto.Board +} + +type TestParameterBundles []TestParameterBundle + +func (testElements TestParameterBundles) Append(name string, expectedCode int, err error, sessionExists bool, sessionRequestExists bool, board *dto.Board) *TestParameterBundles { + t := append(testElements, + newTestParameterBundleBuilder(). + setName(name). + setExpectedCode(expectedCode). + setError(err). + setSessionExists(sessionExists). + setSessionRequestExists(sessionRequestExists). + setBoard(board). + build()) + return &t +} + +func newTestParameterBundleBuilder() *TestParameterBundleBuilder { + return &TestParameterBundleBuilder{} +} + +func (t *TestParameterBundleBuilder) setName(name string) *TestParameterBundleBuilder { + t.name = name + return t +} + +func (t *TestParameterBundleBuilder) setExpectedCode(code int) *TestParameterBundleBuilder { + t.expectedCode = code + return t +} + +func (t *TestParameterBundleBuilder) setError(err error) *TestParameterBundleBuilder { + t.err = err + return t +} + +func (t *TestParameterBundleBuilder) setSessionExists(sessionExists bool) *TestParameterBundleBuilder { + t.sessionExists = sessionExists + return t +} + +func (t *TestParameterBundleBuilder) setSessionRequestExists(sessionRequestExists bool) *TestParameterBundleBuilder { + t.sessionRequestExists = sessionRequestExists + return t +} + +func (t *TestParameterBundleBuilder) setBoard(board *dto.Board) *TestParameterBundleBuilder { + t.board = board + return t +} + +func (t *TestParameterBundleBuilder) build() TestParameterBundle { + return TestParameterBundle{ + name: t.name, + expectedCode: t.expectedCode, + err: t.err, + sessionRequestExists: t.sessionRequestExists, + sessionExists: t.sessionExists, + board: t.board, + } +} From 75c65d9695c47ee6f0f1a54a2c3924ed70960a50 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 16:00:14 +0100 Subject: [PATCH 17/27] feat: commit mockery generated interface implementations --- .../src/mocks/services/mock_BoardReactions.go | 74 ++ .../src/mocks/services/mock_BoardSessions.go | 906 ++++++++++++++++++ .../src/mocks/services/mock_BoardTemplates.go | 608 ++++++++++++ server/src/mocks/services/mock_Boards.go | 905 +++++++++++++++++ server/src/mocks/services/mock_Feedback.go | 130 +++ server/src/mocks/services/mock_Health.go | 122 +++ server/src/mocks/services/mock_Notes.go | 382 ++++++++ server/src/mocks/services/mock_Reactions.go | 328 +++++++ server/src/mocks/services/mock_Users.go | 582 +++++++++++ server/src/mocks/services/mock_Votings.go | 443 +++++++++ 10 files changed, 4480 insertions(+) create mode 100644 server/src/mocks/services/mock_BoardReactions.go create mode 100644 server/src/mocks/services/mock_BoardSessions.go create mode 100644 server/src/mocks/services/mock_BoardTemplates.go create mode 100644 server/src/mocks/services/mock_Boards.go create mode 100644 server/src/mocks/services/mock_Feedback.go create mode 100644 server/src/mocks/services/mock_Health.go create mode 100644 server/src/mocks/services/mock_Notes.go create mode 100644 server/src/mocks/services/mock_Reactions.go create mode 100644 server/src/mocks/services/mock_Users.go create mode 100644 server/src/mocks/services/mock_Votings.go diff --git a/server/src/mocks/services/mock_BoardReactions.go b/server/src/mocks/services/mock_BoardReactions.go new file mode 100644 index 0000000000..0eee513361 --- /dev/null +++ b/server/src/mocks/services/mock_BoardReactions.go @@ -0,0 +1,74 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockBoardReactions is an autogenerated mock type for the BoardReactions type +type MockBoardReactions struct { + mock.Mock +} + +type MockBoardReactions_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoardReactions) EXPECT() *MockBoardReactions_Expecter { + return &MockBoardReactions_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, board, body +func (_m *MockBoardReactions) Create(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest) { + _m.Called(ctx, board, body) +} + +// MockBoardReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoardReactions_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - body dto.BoardReactionCreateRequest +func (_e *MockBoardReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockBoardReactions_Create_Call { + return &MockBoardReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} +} + +func (_c *MockBoardReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.BoardReactionCreateRequest)) + }) + return _c +} + +func (_c *MockBoardReactions_Create_Call) Return() *MockBoardReactions_Create_Call { + _c.Call.Return() + return _c +} + +func (_c *MockBoardReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { + _c.Run(run) + return _c +} + +// NewMockBoardReactions creates a new instance of MockBoardReactions. 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 NewMockBoardReactions(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoardReactions { + mock := &MockBoardReactions{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_BoardSessions.go b/server/src/mocks/services/mock_BoardSessions.go new file mode 100644 index 0000000000..bc2cac6dfd --- /dev/null +++ b/server/src/mocks/services/mock_BoardSessions.go @@ -0,0 +1,906 @@ +// 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" +) + +// MockBoardSessions is an autogenerated mock type for the BoardSessions type +type MockBoardSessions struct { + mock.Mock +} + +type MockBoardSessions_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoardSessions) EXPECT() *MockBoardSessions_Expecter { + return &MockBoardSessions_Expecter{mock: &_m.Mock} +} + +// Connect provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Connect(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) error { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Connect") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardSessions_Connect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Connect' +type MockBoardSessions_Connect_Call struct { + *mock.Call +} + +// Connect is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Connect(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Connect_Call { + return &MockBoardSessions_Connect_Call{Call: _e.mock.On("Connect", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Connect_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_Connect_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 *MockBoardSessions_Connect_Call) Return(_a0 error) *MockBoardSessions_Connect_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardSessions_Connect_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) error) *MockBoardSessions_Connect_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Create(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSession, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSession); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoardSessions_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Create(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Create_Call { + return &MockBoardSessions_Create_Call{Call: _e.mock.On("Create", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Create_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_Create_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 *MockBoardSessions_Create_Call) Return(_a0 *dto.BoardSession, _a1 error) *MockBoardSessions_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)) *MockBoardSessions_Create_Call { + _c.Call.Return(run) + return _c +} + +// CreateSessionRequest provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) CreateSessionRequest(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for CreateSessionRequest") + } + + var r0 *dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSessionRequest); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_CreateSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSessionRequest' +type MockBoardSessions_CreateSessionRequest_Call struct { + *mock.Call +} + +// CreateSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) CreateSessionRequest(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_CreateSessionRequest_Call { + return &MockBoardSessions_CreateSessionRequest_Call{Call: _e.mock.On("CreateSessionRequest", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_CreateSessionRequest_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_CreateSessionRequest_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 *MockBoardSessions_CreateSessionRequest_Call) Return(_a0 *dto.BoardSessionRequest, _a1 error) *MockBoardSessions_CreateSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_CreateSessionRequest_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)) *MockBoardSessions_CreateSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// Disconnect provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Disconnect(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) error { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Disconnect") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardSessions_Disconnect_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Disconnect' +type MockBoardSessions_Disconnect_Call struct { + *mock.Call +} + +// Disconnect is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Disconnect(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Disconnect_Call { + return &MockBoardSessions_Disconnect_Call{Call: _e.mock.On("Disconnect", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Disconnect_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_Disconnect_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 *MockBoardSessions_Disconnect_Call) Return(_a0 error) *MockBoardSessions_Disconnect_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardSessions_Disconnect_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) error) *MockBoardSessions_Disconnect_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) Get(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSession, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSession); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockBoardSessions_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) Get(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_Get_Call { + return &MockBoardSessions_Get_Call{Call: _e.mock.On("Get", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_Get_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_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 *MockBoardSessions_Get_Call) Return(_a0 *dto.BoardSession, _a1 error) *MockBoardSessions_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSession, error)) *MockBoardSessions_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetSessionRequest provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) GetSessionRequest(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for GetSessionRequest") + } + + var r0 *dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.BoardSessionRequest); ok { + r0 = rf(ctx, boardID, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_GetSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSessionRequest' +type MockBoardSessions_GetSessionRequest_Call struct { + *mock.Call +} + +// GetSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) GetSessionRequest(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_GetSessionRequest_Call { + return &MockBoardSessions_GetSessionRequest_Call{Call: _e.mock.On("GetSessionRequest", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_GetSessionRequest_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_GetSessionRequest_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 *MockBoardSessions_GetSessionRequest_Call) Return(_a0 *dto.BoardSessionRequest, _a1 error) *MockBoardSessions_GetSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_GetSessionRequest_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.BoardSessionRequest, error)) *MockBoardSessions_GetSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, boardID, f +func (_m *MockBoardSessions) List(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter) ([]*dto.BoardSession, error) { + ret := _m.Called(ctx, boardID, f) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, filter.BoardSessionFilter) ([]*dto.BoardSession, error)); ok { + return rf(ctx, boardID, f) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, filter.BoardSessionFilter) []*dto.BoardSession); ok { + r0 = rf(ctx, boardID, f) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, filter.BoardSessionFilter) error); ok { + r1 = rf(ctx, boardID, f) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockBoardSessions_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - f filter.BoardSessionFilter +func (_e *MockBoardSessions_Expecter) List(ctx interface{}, boardID interface{}, f interface{}) *MockBoardSessions_List_Call { + return &MockBoardSessions_List_Call{Call: _e.mock.On("List", ctx, boardID, f)} +} + +func (_c *MockBoardSessions_List_Call) Run(run func(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter)) *MockBoardSessions_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(filter.BoardSessionFilter)) + }) + return _c +} + +func (_c *MockBoardSessions_List_Call) Return(_a0 []*dto.BoardSession, _a1 error) *MockBoardSessions_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_List_Call) RunAndReturn(run func(context.Context, uuid.UUID, filter.BoardSessionFilter) ([]*dto.BoardSession, error)) *MockBoardSessions_List_Call { + _c.Call.Return(run) + return _c +} + +// ListSessionRequest provides a mock function with given fields: ctx, boardID, statusQuery +func (_m *MockBoardSessions) ListSessionRequest(ctx context.Context, boardID uuid.UUID, statusQuery string) ([]*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, boardID, statusQuery) + + if len(ret) == 0 { + panic("no return value specified for ListSessionRequest") + } + + var r0 []*dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string) ([]*dto.BoardSessionRequest, error)); ok { + return rf(ctx, boardID, statusQuery) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, string) []*dto.BoardSessionRequest); ok { + r0 = rf(ctx, boardID, statusQuery) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, string) error); ok { + r1 = rf(ctx, boardID, statusQuery) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_ListSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSessionRequest' +type MockBoardSessions_ListSessionRequest_Call struct { + *mock.Call +} + +// ListSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - statusQuery string +func (_e *MockBoardSessions_Expecter) ListSessionRequest(ctx interface{}, boardID interface{}, statusQuery interface{}) *MockBoardSessions_ListSessionRequest_Call { + return &MockBoardSessions_ListSessionRequest_Call{Call: _e.mock.On("ListSessionRequest", ctx, boardID, statusQuery)} +} + +func (_c *MockBoardSessions_ListSessionRequest_Call) Run(run func(ctx context.Context, boardID uuid.UUID, statusQuery string)) *MockBoardSessions_ListSessionRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(string)) + }) + return _c +} + +func (_c *MockBoardSessions_ListSessionRequest_Call) Return(_a0 []*dto.BoardSessionRequest, _a1 error) *MockBoardSessions_ListSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_ListSessionRequest_Call) RunAndReturn(run func(context.Context, uuid.UUID, string) ([]*dto.BoardSessionRequest, error)) *MockBoardSessions_ListSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// ModeratorSessionExists provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) ModeratorSessionExists(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for ModeratorSessionExists") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_ModeratorSessionExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ModeratorSessionExists' +type MockBoardSessions_ModeratorSessionExists_Call struct { + *mock.Call +} + +// ModeratorSessionExists is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) ModeratorSessionExists(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_ModeratorSessionExists_Call { + return &MockBoardSessions_ModeratorSessionExists_Call{Call: _e.mock.On("ModeratorSessionExists", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_ModeratorSessionExists_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_ModeratorSessionExists_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 *MockBoardSessions_ModeratorSessionExists_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_ModeratorSessionExists_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_ModeratorSessionExists_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_ModeratorSessionExists_Call { + _c.Call.Return(run) + return _c +} + +// ParticipantBanned provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) ParticipantBanned(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for ParticipantBanned") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_ParticipantBanned_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ParticipantBanned' +type MockBoardSessions_ParticipantBanned_Call struct { + *mock.Call +} + +// ParticipantBanned is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) ParticipantBanned(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_ParticipantBanned_Call { + return &MockBoardSessions_ParticipantBanned_Call{Call: _e.mock.On("ParticipantBanned", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_ParticipantBanned_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_ParticipantBanned_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 *MockBoardSessions_ParticipantBanned_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_ParticipantBanned_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_ParticipantBanned_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_ParticipantBanned_Call { + _c.Call.Return(run) + return _c +} + +// SessionExists provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) SessionExists(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for SessionExists") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_SessionExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SessionExists' +type MockBoardSessions_SessionExists_Call struct { + *mock.Call +} + +// SessionExists is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) SessionExists(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_SessionExists_Call { + return &MockBoardSessions_SessionExists_Call{Call: _e.mock.On("SessionExists", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_SessionExists_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_SessionExists_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 *MockBoardSessions_SessionExists_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_SessionExists_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_SessionExists_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_SessionExists_Call { + _c.Call.Return(run) + return _c +} + +// SessionRequestExists provides a mock function with given fields: ctx, boardID, userID +func (_m *MockBoardSessions) SessionRequestExists(ctx context.Context, boardID uuid.UUID, userID uuid.UUID) (bool, error) { + ret := _m.Called(ctx, boardID, userID) + + if len(ret) == 0 { + panic("no return value specified for SessionRequestExists") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (bool, error)); ok { + return rf(ctx, boardID, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) bool); ok { + r0 = rf(ctx, boardID, userID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_SessionRequestExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SessionRequestExists' +type MockBoardSessions_SessionRequestExists_Call struct { + *mock.Call +} + +// SessionRequestExists is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - userID uuid.UUID +func (_e *MockBoardSessions_Expecter) SessionRequestExists(ctx interface{}, boardID interface{}, userID interface{}) *MockBoardSessions_SessionRequestExists_Call { + return &MockBoardSessions_SessionRequestExists_Call{Call: _e.mock.On("SessionRequestExists", ctx, boardID, userID)} +} + +func (_c *MockBoardSessions_SessionRequestExists_Call) Run(run func(ctx context.Context, boardID uuid.UUID, userID uuid.UUID)) *MockBoardSessions_SessionRequestExists_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 *MockBoardSessions_SessionRequestExists_Call) Return(_a0 bool, _a1 error) *MockBoardSessions_SessionRequestExists_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_SessionRequestExists_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (bool, error)) *MockBoardSessions_SessionRequestExists_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockBoardSessions) Update(ctx context.Context, body dto.BoardSessionUpdateRequest) (*dto.BoardSession, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionUpdateRequest) (*dto.BoardSession, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionUpdateRequest) *dto.BoardSession); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardSessionUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockBoardSessions_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardSessionUpdateRequest +func (_e *MockBoardSessions_Expecter) Update(ctx interface{}, body interface{}) *MockBoardSessions_Update_Call { + return &MockBoardSessions_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockBoardSessions_Update_Call) Run(run func(ctx context.Context, body dto.BoardSessionUpdateRequest)) *MockBoardSessions_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardSessionUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardSessions_Update_Call) Return(_a0 *dto.BoardSession, _a1 error) *MockBoardSessions_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_Update_Call) RunAndReturn(run func(context.Context, dto.BoardSessionUpdateRequest) (*dto.BoardSession, error)) *MockBoardSessions_Update_Call { + _c.Call.Return(run) + return _c +} + +// UpdateAll provides a mock function with given fields: ctx, body +func (_m *MockBoardSessions) UpdateAll(ctx context.Context, body dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateAll") + } + + var r0 []*dto.BoardSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionsUpdateRequest) []*dto.BoardSession); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardSessionsUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_UpdateAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateAll' +type MockBoardSessions_UpdateAll_Call struct { + *mock.Call +} + +// UpdateAll is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardSessionsUpdateRequest +func (_e *MockBoardSessions_Expecter) UpdateAll(ctx interface{}, body interface{}) *MockBoardSessions_UpdateAll_Call { + return &MockBoardSessions_UpdateAll_Call{Call: _e.mock.On("UpdateAll", ctx, body)} +} + +func (_c *MockBoardSessions_UpdateAll_Call) Run(run func(ctx context.Context, body dto.BoardSessionsUpdateRequest)) *MockBoardSessions_UpdateAll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardSessionsUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardSessions_UpdateAll_Call) Return(_a0 []*dto.BoardSession, _a1 error) *MockBoardSessions_UpdateAll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_UpdateAll_Call) RunAndReturn(run func(context.Context, dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error)) *MockBoardSessions_UpdateAll_Call { + _c.Call.Return(run) + return _c +} + +// UpdateSessionRequest provides a mock function with given fields: ctx, body +func (_m *MockBoardSessions) UpdateSessionRequest(ctx context.Context, body dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateSessionRequest") + } + + var r0 *dto.BoardSessionRequest + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardSessionRequestUpdate) *dto.BoardSessionRequest); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardSessionRequest) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardSessionRequestUpdate) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardSessions_UpdateSessionRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateSessionRequest' +type MockBoardSessions_UpdateSessionRequest_Call struct { + *mock.Call +} + +// UpdateSessionRequest is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardSessionRequestUpdate +func (_e *MockBoardSessions_Expecter) UpdateSessionRequest(ctx interface{}, body interface{}) *MockBoardSessions_UpdateSessionRequest_Call { + return &MockBoardSessions_UpdateSessionRequest_Call{Call: _e.mock.On("UpdateSessionRequest", ctx, body)} +} + +func (_c *MockBoardSessions_UpdateSessionRequest_Call) Run(run func(ctx context.Context, body dto.BoardSessionRequestUpdate)) *MockBoardSessions_UpdateSessionRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardSessionRequestUpdate)) + }) + return _c +} + +func (_c *MockBoardSessions_UpdateSessionRequest_Call) Return(_a0 *dto.BoardSessionRequest, _a1 error) *MockBoardSessions_UpdateSessionRequest_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardSessions_UpdateSessionRequest_Call) RunAndReturn(run func(context.Context, dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error)) *MockBoardSessions_UpdateSessionRequest_Call { + _c.Call.Return(run) + return _c +} + +// NewMockBoardSessions creates a new instance of MockBoardSessions. 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 NewMockBoardSessions(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoardSessions { + mock := &MockBoardSessions{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_BoardTemplates.go b/server/src/mocks/services/mock_BoardTemplates.go new file mode 100644 index 0000000000..5511784877 --- /dev/null +++ b/server/src/mocks/services/mock_BoardTemplates.go @@ -0,0 +1,608 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockBoardTemplates is an autogenerated mock type for the BoardTemplates type +type MockBoardTemplates struct { + mock.Mock +} + +type MockBoardTemplates_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoardTemplates) EXPECT() *MockBoardTemplates_Expecter { + return &MockBoardTemplates_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) Create(ctx context.Context, body dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.BoardTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) *dto.BoardTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.CreateBoardTemplateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoardTemplates_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.CreateBoardTemplateRequest +func (_e *MockBoardTemplates_Expecter) Create(ctx interface{}, body interface{}) *MockBoardTemplates_Create_Call { + return &MockBoardTemplates_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockBoardTemplates_Create_Call) Run(run func(ctx context.Context, body dto.CreateBoardTemplateRequest)) *MockBoardTemplates_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.CreateBoardTemplateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_Create_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_Create_Call) RunAndReturn(run func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Create_Call { + _c.Call.Return(run) + return _c +} + +// CreateColumnTemplate provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) CreateColumnTemplate(ctx context.Context, body dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for CreateColumnTemplate") + } + + var r0 *dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) *dto.ColumnTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.ColumnTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_CreateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateColumnTemplate' +type MockBoardTemplates_CreateColumnTemplate_Call struct { + *mock.Call +} + +// CreateColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnTemplateRequest +func (_e *MockBoardTemplates_Expecter) CreateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_CreateColumnTemplate_Call { + return &MockBoardTemplates_CreateColumnTemplate_Call{Call: _e.mock.On("CreateColumnTemplate", ctx, body)} +} + +func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateRequest)) *MockBoardTemplates_CreateColumnTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnTemplateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_CreateColumnTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_CreateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_CreateColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, id +func (_m *MockBoardTemplates) Delete(ctx context.Context, id uuid.UUID) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardTemplates_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockBoardTemplates_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoardTemplates_Expecter) Delete(ctx interface{}, id interface{}) *MockBoardTemplates_Delete_Call { + return &MockBoardTemplates_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} +} + +func (_c *MockBoardTemplates_Delete_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_Delete_Call) Return(_a0 error) *MockBoardTemplates_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardTemplates_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID) error) *MockBoardTemplates_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteColumnTemplate provides a mock function with given fields: ctx, boar, column, user +func (_m *MockBoardTemplates) DeleteColumnTemplate(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID) error { + ret := _m.Called(ctx, boar, column, user) + + if len(ret) == 0 { + panic("no return value specified for DeleteColumnTemplate") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, boar, column, user) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoardTemplates_DeleteColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteColumnTemplate' +type MockBoardTemplates_DeleteColumnTemplate_Call struct { + *mock.Call +} + +// DeleteColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - boar uuid.UUID +// - column uuid.UUID +// - user uuid.UUID +func (_e *MockBoardTemplates_Expecter) DeleteColumnTemplate(ctx interface{}, boar interface{}, column interface{}, user interface{}) *MockBoardTemplates_DeleteColumnTemplate_Call { + return &MockBoardTemplates_DeleteColumnTemplate_Call{Call: _e.mock.On("DeleteColumnTemplate", ctx, boar, column, user)} +} + +func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Run(run func(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID)) *MockBoardTemplates_DeleteColumnTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Return(_a0 error) *MockBoardTemplates_DeleteColumnTemplate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockBoardTemplates_DeleteColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockBoardTemplates) Get(ctx context.Context, id uuid.UUID) (*dto.BoardTemplate, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.BoardTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.BoardTemplate); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockBoardTemplates_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoardTemplates_Expecter) Get(ctx interface{}, id interface{}) *MockBoardTemplates_Get_Call { + return &MockBoardTemplates_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockBoardTemplates_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_Get_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)) *MockBoardTemplates_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetColumnTemplate provides a mock function with given fields: ctx, boardID, columnID +func (_m *MockBoardTemplates) GetColumnTemplate(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, boardID, columnID) + + if len(ret) == 0 { + panic("no return value specified for GetColumnTemplate") + } + + var r0 *dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)); ok { + return rf(ctx, boardID, columnID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.ColumnTemplate); ok { + r0 = rf(ctx, boardID, columnID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.ColumnTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, columnID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_GetColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetColumnTemplate' +type MockBoardTemplates_GetColumnTemplate_Call struct { + *mock.Call +} + +// GetColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - columnID uuid.UUID +func (_e *MockBoardTemplates_Expecter) GetColumnTemplate(ctx interface{}, boardID interface{}, columnID interface{}) *MockBoardTemplates_GetColumnTemplate_Call { + return &MockBoardTemplates_GetColumnTemplate_Call{Call: _e.mock.On("GetColumnTemplate", ctx, boardID, columnID)} +} + +func (_c *MockBoardTemplates_GetColumnTemplate_Call) Run(run func(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID)) *MockBoardTemplates_GetColumnTemplate_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 *MockBoardTemplates_GetColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_GetColumnTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_GetColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)) *MockBoardTemplates_GetColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, user +func (_m *MockBoardTemplates) List(ctx context.Context, user uuid.UUID) ([]*dto.BoardTemplateFull, error) { + ret := _m.Called(ctx, user) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.BoardTemplateFull + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)); ok { + return rf(ctx, user) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.BoardTemplateFull); ok { + r0 = rf(ctx, user) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardTemplateFull) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, user) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockBoardTemplates_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - user uuid.UUID +func (_e *MockBoardTemplates_Expecter) List(ctx interface{}, user interface{}) *MockBoardTemplates_List_Call { + return &MockBoardTemplates_List_Call{Call: _e.mock.On("List", ctx, user)} +} + +func (_c *MockBoardTemplates_List_Call) Run(run func(ctx context.Context, user uuid.UUID)) *MockBoardTemplates_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_List_Call) Return(_a0 []*dto.BoardTemplateFull, _a1 error) *MockBoardTemplates_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)) *MockBoardTemplates_List_Call { + _c.Call.Return(run) + return _c +} + +// ListColumnTemplates provides a mock function with given fields: ctx, board +func (_m *MockBoardTemplates) ListColumnTemplates(ctx context.Context, board uuid.UUID) ([]*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, board) + + if len(ret) == 0 { + panic("no return value specified for ListColumnTemplates") + } + + var r0 []*dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)); ok { + return rf(ctx, board) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.ColumnTemplate); ok { + r0 = rf(ctx, board) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.ColumnTemplate) + } + } + + 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 +} + +// MockBoardTemplates_ListColumnTemplates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListColumnTemplates' +type MockBoardTemplates_ListColumnTemplates_Call struct { + *mock.Call +} + +// ListColumnTemplates is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +func (_e *MockBoardTemplates_Expecter) ListColumnTemplates(ctx interface{}, board interface{}) *MockBoardTemplates_ListColumnTemplates_Call { + return &MockBoardTemplates_ListColumnTemplates_Call{Call: _e.mock.On("ListColumnTemplates", ctx, board)} +} + +func (_c *MockBoardTemplates_ListColumnTemplates_Call) Run(run func(ctx context.Context, board uuid.UUID)) *MockBoardTemplates_ListColumnTemplates_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoardTemplates_ListColumnTemplates_Call) Return(_a0 []*dto.ColumnTemplate, _a1 error) *MockBoardTemplates_ListColumnTemplates_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_ListColumnTemplates_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)) *MockBoardTemplates_ListColumnTemplates_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) Update(ctx context.Context, body dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.BoardTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) *dto.BoardTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.BoardTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardTemplateUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockBoardTemplates_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardTemplateUpdateRequest +func (_e *MockBoardTemplates_Expecter) Update(ctx interface{}, body interface{}) *MockBoardTemplates_Update_Call { + return &MockBoardTemplates_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockBoardTemplates_Update_Call) Run(run func(ctx context.Context, body dto.BoardTemplateUpdateRequest)) *MockBoardTemplates_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardTemplateUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_Update_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_Update_Call) RunAndReturn(run func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Update_Call { + _c.Call.Return(run) + return _c +} + +// UpdateColumnTemplate provides a mock function with given fields: ctx, body +func (_m *MockBoardTemplates) UpdateColumnTemplate(ctx context.Context, body dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateColumnTemplate") + } + + var r0 *dto.ColumnTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) *dto.ColumnTemplate); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.ColumnTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoardTemplates_UpdateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateColumnTemplate' +type MockBoardTemplates_UpdateColumnTemplate_Call struct { + *mock.Call +} + +// UpdateColumnTemplate is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnTemplateUpdateRequest +func (_e *MockBoardTemplates_Expecter) UpdateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_UpdateColumnTemplate_Call { + return &MockBoardTemplates_UpdateColumnTemplate_Call{Call: _e.mock.On("UpdateColumnTemplate", ctx, body)} +} + +func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateUpdateRequest)) *MockBoardTemplates_UpdateColumnTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnTemplateUpdateRequest)) + }) + return _c +} + +func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_UpdateColumnTemplate_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_UpdateColumnTemplate_Call { + _c.Call.Return(run) + return _c +} + +// NewMockBoardTemplates creates a new instance of MockBoardTemplates. 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 NewMockBoardTemplates(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoardTemplates { + mock := &MockBoardTemplates{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Boards.go b/server/src/mocks/services/mock_Boards.go new file mode 100644 index 0000000000..34ade264b0 --- /dev/null +++ b/server/src/mocks/services/mock_Boards.go @@ -0,0 +1,905 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockBoards is an autogenerated mock type for the Boards type +type MockBoards struct { + mock.Mock +} + +type MockBoards_Expecter struct { + mock *mock.Mock +} + +func (_m *MockBoards) EXPECT() *MockBoards_Expecter { + return &MockBoards_Expecter{mock: &_m.Mock} +} + +// BoardOverview provides a mock function with given fields: ctx, boardIDs, user +func (_m *MockBoards) BoardOverview(ctx context.Context, boardIDs []uuid.UUID, user uuid.UUID) ([]*dto.BoardOverview, error) { + ret := _m.Called(ctx, boardIDs, user) + + if len(ret) == 0 { + panic("no return value specified for BoardOverview") + } + + var r0 []*dto.BoardOverview + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []uuid.UUID, uuid.UUID) ([]*dto.BoardOverview, error)); ok { + return rf(ctx, boardIDs, user) + } + if rf, ok := ret.Get(0).(func(context.Context, []uuid.UUID, uuid.UUID) []*dto.BoardOverview); ok { + r0 = rf(ctx, boardIDs, user) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.BoardOverview) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardIDs, user) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_BoardOverview_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BoardOverview' +type MockBoards_BoardOverview_Call struct { + *mock.Call +} + +// BoardOverview is a helper method to define mock.On call +// - ctx context.Context +// - boardIDs []uuid.UUID +// - user uuid.UUID +func (_e *MockBoards_Expecter) BoardOverview(ctx interface{}, boardIDs interface{}, user interface{}) *MockBoards_BoardOverview_Call { + return &MockBoards_BoardOverview_Call{Call: _e.mock.On("BoardOverview", ctx, boardIDs, user)} +} + +func (_c *MockBoards_BoardOverview_Call) Run(run func(ctx context.Context, boardIDs []uuid.UUID, user uuid.UUID)) *MockBoards_BoardOverview_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 *MockBoards_BoardOverview_Call) Return(_a0 []*dto.BoardOverview, _a1 error) *MockBoards_BoardOverview_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_BoardOverview_Call) RunAndReturn(run func(context.Context, []uuid.UUID, uuid.UUID) ([]*dto.BoardOverview, error)) *MockBoards_BoardOverview_Call { + _c.Call.Return(run) + return _c +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockBoards) Create(ctx context.Context, body dto.CreateBoardRequest) (*dto.Board, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardRequest) (*dto.Board, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardRequest) *dto.Board); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.CreateBoardRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockBoards_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.CreateBoardRequest +func (_e *MockBoards_Expecter) Create(ctx interface{}, body interface{}) *MockBoards_Create_Call { + return &MockBoards_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockBoards_Create_Call) Run(run func(ctx context.Context, body dto.CreateBoardRequest)) *MockBoards_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.CreateBoardRequest)) + }) + return _c +} + +func (_c *MockBoards_Create_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_Create_Call) RunAndReturn(run func(context.Context, dto.CreateBoardRequest) (*dto.Board, error)) *MockBoards_Create_Call { + _c.Call.Return(run) + return _c +} + +// CreateColumn provides a mock function with given fields: ctx, body +func (_m *MockBoards) CreateColumn(ctx context.Context, body dto.ColumnRequest) (*dto.Column, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for CreateColumn") + } + + var r0 *dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) (*dto.Column, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) *dto.Column); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_CreateColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateColumn' +type MockBoards_CreateColumn_Call struct { + *mock.Call +} + +// CreateColumn is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnRequest +func (_e *MockBoards_Expecter) CreateColumn(ctx interface{}, body interface{}) *MockBoards_CreateColumn_Call { + return &MockBoards_CreateColumn_Call{Call: _e.mock.On("CreateColumn", ctx, body)} +} + +func (_c *MockBoards_CreateColumn_Call) Run(run func(ctx context.Context, body dto.ColumnRequest)) *MockBoards_CreateColumn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnRequest)) + }) + return _c +} + +func (_c *MockBoards_CreateColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_CreateColumn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_CreateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnRequest) (*dto.Column, error)) *MockBoards_CreateColumn_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, id +func (_m *MockBoards) Delete(ctx context.Context, id uuid.UUID) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoards_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockBoards_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) Delete(ctx interface{}, id interface{}) *MockBoards_Delete_Call { + return &MockBoards_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} +} + +func (_c *MockBoards_Delete_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_Delete_Call) Return(_a0 error) *MockBoards_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoards_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID) error) *MockBoards_Delete_Call { + _c.Call.Return(run) + return _c +} + +// DeleteColumn provides a mock function with given fields: ctx, board, column, user +func (_m *MockBoards) DeleteColumn(ctx context.Context, board uuid.UUID, column uuid.UUID, user uuid.UUID) error { + ret := _m.Called(ctx, board, column, user) + + if len(ret) == 0 { + panic("no return value specified for DeleteColumn") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, board, column, user) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockBoards_DeleteColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteColumn' +type MockBoards_DeleteColumn_Call struct { + *mock.Call +} + +// DeleteColumn is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - column uuid.UUID +// - user uuid.UUID +func (_e *MockBoards_Expecter) DeleteColumn(ctx interface{}, board interface{}, column interface{}, user interface{}) *MockBoards_DeleteColumn_Call { + return &MockBoards_DeleteColumn_Call{Call: _e.mock.On("DeleteColumn", ctx, board, column, user)} +} + +func (_c *MockBoards_DeleteColumn_Call) Run(run func(ctx context.Context, board uuid.UUID, column uuid.UUID, user uuid.UUID)) *MockBoards_DeleteColumn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_DeleteColumn_Call) Return(_a0 error) *MockBoards_DeleteColumn_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockBoards_DeleteColumn_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockBoards_DeleteColumn_Call { + _c.Call.Return(run) + return _c +} + +// DeleteTimer provides a mock function with given fields: ctx, id +func (_m *MockBoards) DeleteTimer(ctx context.Context, id uuid.UUID) (*dto.Board, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for DeleteTimer") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Board, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Board); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_DeleteTimer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteTimer' +type MockBoards_DeleteTimer_Call struct { + *mock.Call +} + +// DeleteTimer is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) DeleteTimer(ctx interface{}, id interface{}) *MockBoards_DeleteTimer_Call { + return &MockBoards_DeleteTimer_Call{Call: _e.mock.On("DeleteTimer", ctx, id)} +} + +func (_c *MockBoards_DeleteTimer_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_DeleteTimer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_DeleteTimer_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_DeleteTimer_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_DeleteTimer_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Board, error)) *MockBoards_DeleteTimer_Call { + _c.Call.Return(run) + return _c +} + +// FullBoard provides a mock function with given fields: ctx, boardID +func (_m *MockBoards) FullBoard(ctx context.Context, boardID uuid.UUID) (*dto.FullBoard, error) { + ret := _m.Called(ctx, boardID) + + if len(ret) == 0 { + panic("no return value specified for FullBoard") + } + + var r0 *dto.FullBoard + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.FullBoard, error)); ok { + return rf(ctx, boardID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.FullBoard); ok { + r0 = rf(ctx, boardID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.FullBoard) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, boardID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_FullBoard_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FullBoard' +type MockBoards_FullBoard_Call struct { + *mock.Call +} + +// FullBoard is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +func (_e *MockBoards_Expecter) FullBoard(ctx interface{}, boardID interface{}) *MockBoards_FullBoard_Call { + return &MockBoards_FullBoard_Call{Call: _e.mock.On("FullBoard", ctx, boardID)} +} + +func (_c *MockBoards_FullBoard_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockBoards_FullBoard_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_FullBoard_Call) Return(_a0 *dto.FullBoard, _a1 error) *MockBoards_FullBoard_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_FullBoard_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.FullBoard, error)) *MockBoards_FullBoard_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockBoards) Get(ctx context.Context, id uuid.UUID) (*dto.Board, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Board, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Board); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockBoards_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) Get(ctx interface{}, id interface{}) *MockBoards_Get_Call { + return &MockBoards_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockBoards_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_Get_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Board, error)) *MockBoards_Get_Call { + _c.Call.Return(run) + return _c +} + +// GetBoards provides a mock function with given fields: ctx, userID +func (_m *MockBoards) GetBoards(ctx context.Context, userID uuid.UUID) ([]uuid.UUID, error) { + ret := _m.Called(ctx, userID) + + if len(ret) == 0 { + panic("no return value specified for GetBoards") + } + + var r0 []uuid.UUID + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]uuid.UUID, error)); ok { + return rf(ctx, userID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []uuid.UUID); ok { + r0 = rf(ctx, userID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]uuid.UUID) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, userID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_GetBoards_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBoards' +type MockBoards_GetBoards_Call struct { + *mock.Call +} + +// GetBoards is a helper method to define mock.On call +// - ctx context.Context +// - userID uuid.UUID +func (_e *MockBoards_Expecter) GetBoards(ctx interface{}, userID interface{}) *MockBoards_GetBoards_Call { + return &MockBoards_GetBoards_Call{Call: _e.mock.On("GetBoards", ctx, userID)} +} + +func (_c *MockBoards_GetBoards_Call) Run(run func(ctx context.Context, userID uuid.UUID)) *MockBoards_GetBoards_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_GetBoards_Call) Return(_a0 []uuid.UUID, _a1 error) *MockBoards_GetBoards_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_GetBoards_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]uuid.UUID, error)) *MockBoards_GetBoards_Call { + _c.Call.Return(run) + return _c +} + +// GetColumn provides a mock function with given fields: ctx, boardID, columnID +func (_m *MockBoards) GetColumn(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*dto.Column, error) { + ret := _m.Called(ctx, boardID, columnID) + + if len(ret) == 0 { + panic("no return value specified for GetColumn") + } + + var r0 *dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.Column, error)); ok { + return rf(ctx, boardID, columnID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.Column); ok { + r0 = rf(ctx, boardID, columnID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(ctx, boardID, columnID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_GetColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetColumn' +type MockBoards_GetColumn_Call struct { + *mock.Call +} + +// GetColumn is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +// - columnID uuid.UUID +func (_e *MockBoards_Expecter) GetColumn(ctx interface{}, boardID interface{}, columnID interface{}) *MockBoards_GetColumn_Call { + return &MockBoards_GetColumn_Call{Call: _e.mock.On("GetColumn", ctx, boardID, columnID)} +} + +func (_c *MockBoards_GetColumn_Call) Run(run func(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID)) *MockBoards_GetColumn_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 *MockBoards_GetColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_GetColumn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_GetColumn_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.Column, error)) *MockBoards_GetColumn_Call { + _c.Call.Return(run) + return _c +} + +// IncrementTimer provides a mock function with given fields: ctx, id +func (_m *MockBoards) IncrementTimer(ctx context.Context, id uuid.UUID) (*dto.Board, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for IncrementTimer") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Board, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Board); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_IncrementTimer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IncrementTimer' +type MockBoards_IncrementTimer_Call struct { + *mock.Call +} + +// IncrementTimer is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockBoards_Expecter) IncrementTimer(ctx interface{}, id interface{}) *MockBoards_IncrementTimer_Call { + return &MockBoards_IncrementTimer_Call{Call: _e.mock.On("IncrementTimer", ctx, id)} +} + +func (_c *MockBoards_IncrementTimer_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoards_IncrementTimer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_IncrementTimer_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_IncrementTimer_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_IncrementTimer_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Board, error)) *MockBoards_IncrementTimer_Call { + _c.Call.Return(run) + return _c +} + +// ListColumns provides a mock function with given fields: ctx, boardID +func (_m *MockBoards) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*dto.Column, error) { + ret := _m.Called(ctx, boardID) + + if len(ret) == 0 { + panic("no return value specified for ListColumns") + } + + var r0 []*dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Column, error)); ok { + return rf(ctx, boardID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Column); ok { + r0 = rf(ctx, boardID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, boardID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_ListColumns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListColumns' +type MockBoards_ListColumns_Call struct { + *mock.Call +} + +// ListColumns is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +func (_e *MockBoards_Expecter) ListColumns(ctx interface{}, boardID interface{}) *MockBoards_ListColumns_Call { + return &MockBoards_ListColumns_Call{Call: _e.mock.On("ListColumns", ctx, boardID)} +} + +func (_c *MockBoards_ListColumns_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockBoards_ListColumns_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockBoards_ListColumns_Call) Return(_a0 []*dto.Column, _a1 error) *MockBoards_ListColumns_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_ListColumns_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Column, error)) *MockBoards_ListColumns_Call { + _c.Call.Return(run) + return _c +} + +// SetTimer provides a mock function with given fields: ctx, id, minutes +func (_m *MockBoards) SetTimer(ctx context.Context, id uuid.UUID, minutes uint8) (*dto.Board, error) { + ret := _m.Called(ctx, id, minutes) + + if len(ret) == 0 { + panic("no return value specified for SetTimer") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uint8) (*dto.Board, error)); ok { + return rf(ctx, id, minutes) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uint8) *dto.Board); ok { + r0 = rf(ctx, id, minutes) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uint8) error); ok { + r1 = rf(ctx, id, minutes) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_SetTimer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTimer' +type MockBoards_SetTimer_Call struct { + *mock.Call +} + +// SetTimer is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +// - minutes uint8 +func (_e *MockBoards_Expecter) SetTimer(ctx interface{}, id interface{}, minutes interface{}) *MockBoards_SetTimer_Call { + return &MockBoards_SetTimer_Call{Call: _e.mock.On("SetTimer", ctx, id, minutes)} +} + +func (_c *MockBoards_SetTimer_Call) Run(run func(ctx context.Context, id uuid.UUID, minutes uint8)) *MockBoards_SetTimer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uint8)) + }) + return _c +} + +func (_c *MockBoards_SetTimer_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_SetTimer_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_SetTimer_Call) RunAndReturn(run func(context.Context, uuid.UUID, uint8) (*dto.Board, error)) *MockBoards_SetTimer_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockBoards) Update(ctx context.Context, body dto.BoardUpdateRequest) (*dto.Board, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Board + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardUpdateRequest) (*dto.Board, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.BoardUpdateRequest) *dto.Board); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Board) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.BoardUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockBoards_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.BoardUpdateRequest +func (_e *MockBoards_Expecter) Update(ctx interface{}, body interface{}) *MockBoards_Update_Call { + return &MockBoards_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockBoards_Update_Call) Run(run func(ctx context.Context, body dto.BoardUpdateRequest)) *MockBoards_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.BoardUpdateRequest)) + }) + return _c +} + +func (_c *MockBoards_Update_Call) Return(_a0 *dto.Board, _a1 error) *MockBoards_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_Update_Call) RunAndReturn(run func(context.Context, dto.BoardUpdateRequest) (*dto.Board, error)) *MockBoards_Update_Call { + _c.Call.Return(run) + return _c +} + +// UpdateColumn provides a mock function with given fields: ctx, body +func (_m *MockBoards) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for UpdateColumn") + } + + var r0 *dto.Column + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) (*dto.Column, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) *dto.Column); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Column) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockBoards_UpdateColumn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateColumn' +type MockBoards_UpdateColumn_Call struct { + *mock.Call +} + +// UpdateColumn is a helper method to define mock.On call +// - ctx context.Context +// - body dto.ColumnUpdateRequest +func (_e *MockBoards_Expecter) UpdateColumn(ctx interface{}, body interface{}) *MockBoards_UpdateColumn_Call { + return &MockBoards_UpdateColumn_Call{Call: _e.mock.On("UpdateColumn", ctx, body)} +} + +func (_c *MockBoards_UpdateColumn_Call) Run(run func(ctx context.Context, body dto.ColumnUpdateRequest)) *MockBoards_UpdateColumn_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.ColumnUpdateRequest)) + }) + return _c +} + +func (_c *MockBoards_UpdateColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_UpdateColumn_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockBoards_UpdateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnUpdateRequest) (*dto.Column, error)) *MockBoards_UpdateColumn_Call { + _c.Call.Return(run) + return _c +} + +// NewMockBoards creates a new instance of MockBoards. 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 NewMockBoards(t interface { + mock.TestingT + Cleanup(func()) +}) *MockBoards { + mock := &MockBoards{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Feedback.go b/server/src/mocks/services/mock_Feedback.go new file mode 100644 index 0000000000..1af1cc0bde --- /dev/null +++ b/server/src/mocks/services/mock_Feedback.go @@ -0,0 +1,130 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// MockFeedback is an autogenerated mock type for the Feedback type +type MockFeedback struct { + mock.Mock +} + +type MockFeedback_Expecter struct { + mock *mock.Mock +} + +func (_m *MockFeedback) EXPECT() *MockFeedback_Expecter { + return &MockFeedback_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, feedbackType, contact, text +func (_m *MockFeedback) Create(ctx context.Context, feedbackType string, contact string, text string) error { + ret := _m.Called(ctx, feedbackType, contact, text) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok { + r0 = rf(ctx, feedbackType, contact, text) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockFeedback_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockFeedback_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - feedbackType string +// - contact string +// - text string +func (_e *MockFeedback_Expecter) Create(ctx interface{}, feedbackType interface{}, contact interface{}, text interface{}) *MockFeedback_Create_Call { + return &MockFeedback_Create_Call{Call: _e.mock.On("Create", ctx, feedbackType, contact, text)} +} + +func (_c *MockFeedback_Create_Call) Run(run func(ctx context.Context, feedbackType string, contact string, text string)) *MockFeedback_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockFeedback_Create_Call) Return(_a0 error) *MockFeedback_Create_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFeedback_Create_Call) RunAndReturn(run func(context.Context, string, string, string) error) *MockFeedback_Create_Call { + _c.Call.Return(run) + return _c +} + +// Enabled provides a mock function with no fields +func (_m *MockFeedback) Enabled() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Enabled") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockFeedback_Enabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Enabled' +type MockFeedback_Enabled_Call struct { + *mock.Call +} + +// Enabled is a helper method to define mock.On call +func (_e *MockFeedback_Expecter) Enabled() *MockFeedback_Enabled_Call { + return &MockFeedback_Enabled_Call{Call: _e.mock.On("Enabled")} +} + +func (_c *MockFeedback_Enabled_Call) Run(run func()) *MockFeedback_Enabled_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockFeedback_Enabled_Call) Return(_a0 bool) *MockFeedback_Enabled_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockFeedback_Enabled_Call) RunAndReturn(run func() bool) *MockFeedback_Enabled_Call { + _c.Call.Return(run) + return _c +} + +// NewMockFeedback creates a new instance of MockFeedback. 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 NewMockFeedback(t interface { + mock.TestingT + Cleanup(func()) +}) *MockFeedback { + mock := &MockFeedback{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Health.go b/server/src/mocks/services/mock_Health.go new file mode 100644 index 0000000000..8f4882aa7b --- /dev/null +++ b/server/src/mocks/services/mock_Health.go @@ -0,0 +1,122 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import mock "github.com/stretchr/testify/mock" + +// MockHealth is an autogenerated mock type for the Health type +type MockHealth struct { + mock.Mock +} + +type MockHealth_Expecter struct { + mock *mock.Mock +} + +func (_m *MockHealth) EXPECT() *MockHealth_Expecter { + return &MockHealth_Expecter{mock: &_m.Mock} +} + +// IsDatabaseHealthy provides a mock function with no fields +func (_m *MockHealth) IsDatabaseHealthy() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsDatabaseHealthy") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockHealth_IsDatabaseHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsDatabaseHealthy' +type MockHealth_IsDatabaseHealthy_Call struct { + *mock.Call +} + +// IsDatabaseHealthy is a helper method to define mock.On call +func (_e *MockHealth_Expecter) IsDatabaseHealthy() *MockHealth_IsDatabaseHealthy_Call { + return &MockHealth_IsDatabaseHealthy_Call{Call: _e.mock.On("IsDatabaseHealthy")} +} + +func (_c *MockHealth_IsDatabaseHealthy_Call) Run(run func()) *MockHealth_IsDatabaseHealthy_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockHealth_IsDatabaseHealthy_Call) Return(_a0 bool) *MockHealth_IsDatabaseHealthy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHealth_IsDatabaseHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsDatabaseHealthy_Call { + _c.Call.Return(run) + return _c +} + +// IsRealtimeHealthy provides a mock function with no fields +func (_m *MockHealth) IsRealtimeHealthy() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsRealtimeHealthy") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MockHealth_IsRealtimeHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRealtimeHealthy' +type MockHealth_IsRealtimeHealthy_Call struct { + *mock.Call +} + +// IsRealtimeHealthy is a helper method to define mock.On call +func (_e *MockHealth_Expecter) IsRealtimeHealthy() *MockHealth_IsRealtimeHealthy_Call { + return &MockHealth_IsRealtimeHealthy_Call{Call: _e.mock.On("IsRealtimeHealthy")} +} + +func (_c *MockHealth_IsRealtimeHealthy_Call) Run(run func()) *MockHealth_IsRealtimeHealthy_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockHealth_IsRealtimeHealthy_Call) Return(_a0 bool) *MockHealth_IsRealtimeHealthy_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockHealth_IsRealtimeHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsRealtimeHealthy_Call { + _c.Call.Return(run) + return _c +} + +// NewMockHealth creates a new instance of MockHealth. 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 NewMockHealth(t interface { + mock.TestingT + Cleanup(func()) +}) *MockHealth { + mock := &MockHealth{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Notes.go b/server/src/mocks/services/mock_Notes.go new file mode 100644 index 0000000000..66024de389 --- /dev/null +++ b/server/src/mocks/services/mock_Notes.go @@ -0,0 +1,382 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockNotes is an autogenerated mock type for the Notes type +type MockNotes struct { + mock.Mock +} + +type MockNotes_Expecter struct { + mock *mock.Mock +} + +func (_m *MockNotes) EXPECT() *MockNotes_Expecter { + return &MockNotes_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteCreateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockNotes_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteCreateRequest +func (_e *MockNotes_Expecter) Create(ctx interface{}, body interface{}) *MockNotes_Create_Call { + return &MockNotes_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockNotes_Create_Call) Run(run func(ctx context.Context, body dto.NoteCreateRequest)) *MockNotes_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteCreateRequest)) + }) + return _c +} + +func (_c *MockNotes_Create_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)) *MockNotes_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, body, id +func (_m *MockNotes) Delete(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID) error { + ret := _m.Called(ctx, body, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error); ok { + r0 = rf(ctx, body, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockNotes_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockNotes_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteDeleteRequest +// - id uuid.UUID +func (_e *MockNotes_Expecter) Delete(ctx interface{}, body interface{}, id interface{}) *MockNotes_Delete_Call { + return &MockNotes_Delete_Call{Call: _e.mock.On("Delete", ctx, body, id)} +} + +func (_c *MockNotes_Delete_Call) Run(run func(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID)) *MockNotes_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteDeleteRequest), args[2].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Delete_Call) Return(_a0 error) *MockNotes_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotes_Delete_Call) RunAndReturn(run func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error) *MockNotes_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockNotes_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) Get(ctx interface{}, id interface{}) *MockNotes_Get_Call { + return &MockNotes_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockNotes_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Get_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Note, error)) *MockNotes_Get_Call { + _c.Call.Return(run) + return _c +} + +// Import provides a mock function with given fields: ctx, body +func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Import") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteImportRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Import_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Import' +type MockNotes_Import_Call struct { + *mock.Call +} + +// Import is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteImportRequest +func (_e *MockNotes_Expecter) Import(ctx interface{}, body interface{}) *MockNotes_Import_Call { + return &MockNotes_Import_Call{Call: _e.mock.On("Import", ctx, body)} +} + +func (_c *MockNotes_Import_Call) Run(run func(ctx context.Context, body dto.NoteImportRequest)) *MockNotes_Import_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteImportRequest)) + }) + return _c +} + +func (_c *MockNotes_Import_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Import_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*dto.Note, error)) *MockNotes_Import_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, id +func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockNotes_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) List(ctx interface{}, id interface{}) *MockNotes_List_Call { + return &MockNotes_List_Call{Call: _e.mock.On("List", ctx, id)} +} + +func (_c *MockNotes_List_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_List_Call) Return(_a0 []*dto.Note, _a1 error) *MockNotes_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Note, error)) *MockNotes_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockNotes_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteUpdateRequest +func (_e *MockNotes_Expecter) Update(ctx interface{}, body interface{}) *MockNotes_Update_Call { + return &MockNotes_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockNotes_Update_Call) Run(run func(ctx context.Context, body dto.NoteUpdateRequest)) *MockNotes_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteUpdateRequest)) + }) + return _c +} + +func (_c *MockNotes_Update_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)) *MockNotes_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockNotes creates a new instance of MockNotes. 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 NewMockNotes(t interface { + mock.TestingT + Cleanup(func()) +}) *MockNotes { + mock := &MockNotes{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Reactions.go b/server/src/mocks/services/mock_Reactions.go new file mode 100644 index 0000000000..d798028a82 --- /dev/null +++ b/server/src/mocks/services/mock_Reactions.go @@ -0,0 +1,328 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockReactions is an autogenerated mock type for the Reactions type +type MockReactions struct { + mock.Mock +} + +type MockReactions_Expecter struct { + mock *mock.Mock +} + +func (_m *MockReactions) EXPECT() *MockReactions_Expecter { + return &MockReactions_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, board, body +func (_m *MockReactions) Create(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest) (*dto.Reaction, error) { + ret := _m.Called(ctx, board, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)); ok { + return rf(ctx, board, body) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) *dto.Reaction); ok { + r0 = rf(ctx, board, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) error); ok { + r1 = rf(ctx, board, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockReactions_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - body dto.ReactionCreateRequest +func (_e *MockReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockReactions_Create_Call { + return &MockReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} +} + +func (_c *MockReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest)) *MockReactions_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.ReactionCreateRequest)) + }) + return _c +} + +func (_c *MockReactions_Create_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)) *MockReactions_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, board, user, id +func (_m *MockReactions) Delete(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID) error { + ret := _m.Called(ctx, board, user, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { + r0 = rf(ctx, board, user, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockReactions_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockReactions_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - user uuid.UUID +// - id uuid.UUID +func (_e *MockReactions_Expecter) Delete(ctx interface{}, board interface{}, user interface{}, id interface{}) *MockReactions_Delete_Call { + return &MockReactions_Delete_Call{Call: _e.mock.On("Delete", ctx, board, user, id)} +} + +func (_c *MockReactions_Delete_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID)) *MockReactions_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) + }) + return _c +} + +func (_c *MockReactions_Delete_Call) Return(_a0 error) *MockReactions_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockReactions_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockReactions_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockReactions) Get(ctx context.Context, id uuid.UUID) (*dto.Reaction, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Reaction, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Reaction); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockReactions_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockReactions_Expecter) Get(ctx interface{}, id interface{}) *MockReactions_Get_Call { + return &MockReactions_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockReactions_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockReactions_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockReactions_Get_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Reaction, error)) *MockReactions_Get_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, boardID +func (_m *MockReactions) List(ctx context.Context, boardID uuid.UUID) ([]*dto.Reaction, error) { + ret := _m.Called(ctx, boardID) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Reaction, error)); ok { + return rf(ctx, boardID) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Reaction); ok { + r0 = rf(ctx, boardID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, boardID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockReactions_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - boardID uuid.UUID +func (_e *MockReactions_Expecter) List(ctx interface{}, boardID interface{}) *MockReactions_List_Call { + return &MockReactions_List_Call{Call: _e.mock.On("List", ctx, boardID)} +} + +func (_c *MockReactions_List_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockReactions_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockReactions_List_Call) Return(_a0 []*dto.Reaction, _a1 error) *MockReactions_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Reaction, error)) *MockReactions_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, board, user, id, body +func (_m *MockReactions) Update(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest) (*dto.Reaction, error) { + ret := _m.Called(ctx, board, user, id, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Reaction + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)); ok { + return rf(ctx, board, user, id, body) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) *dto.Reaction); ok { + r0 = rf(ctx, board, user, id, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Reaction) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) error); ok { + r1 = rf(ctx, board, user, id, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockReactions_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockReactions_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - board uuid.UUID +// - user uuid.UUID +// - id uuid.UUID +// - body dto.ReactionUpdateTypeRequest +func (_e *MockReactions_Expecter) Update(ctx interface{}, board interface{}, user interface{}, id interface{}, body interface{}) *MockReactions_Update_Call { + return &MockReactions_Update_Call{Call: _e.mock.On("Update", ctx, board, user, id, body)} +} + +func (_c *MockReactions_Update_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest)) *MockReactions_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID), args[4].(dto.ReactionUpdateTypeRequest)) + }) + return _c +} + +func (_c *MockReactions_Update_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockReactions_Update_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)) *MockReactions_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockReactions creates a new instance of MockReactions. 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 NewMockReactions(t interface { + mock.TestingT + Cleanup(func()) +}) *MockReactions { + mock := &MockReactions{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/server/src/mocks/services/mock_Users.go b/server/src/mocks/services/mock_Users.go new file mode 100644 index 0000000000..e5e9855981 --- /dev/null +++ b/server/src/mocks/services/mock_Users.go @@ -0,0 +1,582 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockUsers is an autogenerated mock type for the Users type +type MockUsers struct { + mock.Mock +} + +type MockUsers_Expecter struct { + mock *mock.Mock +} + +func (_m *MockUsers) EXPECT() *MockUsers_Expecter { + return &MockUsers_Expecter{mock: &_m.Mock} +} + +// CreateAppleUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateAppleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateAppleUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateAppleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAppleUser' +type MockUsers_CreateAppleUser_Call struct { + *mock.Call +} + +// CreateAppleUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateAppleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAppleUser_Call { + return &MockUsers_CreateAppleUser_Call{Call: _e.mock.On("CreateAppleUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateAppleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAppleUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateAppleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAppleUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateAppleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAppleUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateAzureAdUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateAzureAdUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateAzureAdUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateAzureAdUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAzureAdUser' +type MockUsers_CreateAzureAdUser_Call struct { + *mock.Call +} + +// CreateAzureAdUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateAzureAdUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAzureAdUser_Call { + return &MockUsers_CreateAzureAdUser_Call{Call: _e.mock.On("CreateAzureAdUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateAzureAdUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAzureAdUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateAzureAdUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAzureAdUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateAzureAdUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAzureAdUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateGitHubUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateGitHubUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateGitHubUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateGitHubUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGitHubUser' +type MockUsers_CreateGitHubUser_Call struct { + *mock.Call +} + +// CreateGitHubUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateGitHubUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGitHubUser_Call { + return &MockUsers_CreateGitHubUser_Call{Call: _e.mock.On("CreateGitHubUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateGitHubUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGitHubUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateGitHubUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGitHubUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateGitHubUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGitHubUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateGoogleUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateGoogleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateGoogleUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateGoogleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGoogleUser' +type MockUsers_CreateGoogleUser_Call struct { + *mock.Call +} + +// CreateGoogleUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateGoogleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGoogleUser_Call { + return &MockUsers_CreateGoogleUser_Call{Call: _e.mock.On("CreateGoogleUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateGoogleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGoogleUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateGoogleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGoogleUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateGoogleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGoogleUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateMicrosoftUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateMicrosoftUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateMicrosoftUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateMicrosoftUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMicrosoftUser' +type MockUsers_CreateMicrosoftUser_Call struct { + *mock.Call +} + +// CreateMicrosoftUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateMicrosoftUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateMicrosoftUser_Call { + return &MockUsers_CreateMicrosoftUser_Call{Call: _e.mock.On("CreateMicrosoftUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateMicrosoftUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateMicrosoftUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateMicrosoftUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateMicrosoftUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateMicrosoftUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateMicrosoftUser_Call { + _c.Call.Return(run) + return _c +} + +// CreateOIDCUser provides a mock function with given fields: ctx, id, name, avatarUrl +func (_m *MockUsers) CreateOIDCUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { + ret := _m.Called(ctx, id, name, avatarUrl) + + if len(ret) == 0 { + panic("no return value specified for CreateOIDCUser") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { + return rf(ctx, id, name, avatarUrl) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { + r0 = rf(ctx, id, name, avatarUrl) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, id, name, avatarUrl) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_CreateOIDCUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOIDCUser' +type MockUsers_CreateOIDCUser_Call struct { + *mock.Call +} + +// CreateOIDCUser is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - name string +// - avatarUrl string +func (_e *MockUsers_Expecter) CreateOIDCUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateOIDCUser_Call { + return &MockUsers_CreateOIDCUser_Call{Call: _e.mock.On("CreateOIDCUser", ctx, id, name, avatarUrl)} +} + +func (_c *MockUsers_CreateOIDCUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateOIDCUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockUsers_CreateOIDCUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateOIDCUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_CreateOIDCUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateOIDCUser_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockUsers) Get(ctx context.Context, id uuid.UUID) (*dto.User, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.User, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.User); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockUsers_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockUsers_Expecter) Get(ctx interface{}, id interface{}) *MockUsers_Get_Call { + return &MockUsers_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockUsers_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockUsers_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockUsers_Get_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.User, error)) *MockUsers_Get_Call { + _c.Call.Return(run) + return _c +} + +// LoginAnonymous provides a mock function with given fields: ctx, name +func (_m *MockUsers) LoginAnonymous(ctx context.Context, name string) (*dto.User, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for LoginAnonymous") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*dto.User, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *dto.User); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_LoginAnonymous_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoginAnonymous' +type MockUsers_LoginAnonymous_Call struct { + *mock.Call +} + +// LoginAnonymous is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockUsers_Expecter) LoginAnonymous(ctx interface{}, name interface{}) *MockUsers_LoginAnonymous_Call { + return &MockUsers_LoginAnonymous_Call{Call: _e.mock.On("LoginAnonymous", ctx, name)} +} + +func (_c *MockUsers_LoginAnonymous_Call) Run(run func(ctx context.Context, name string)) *MockUsers_LoginAnonymous_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockUsers_LoginAnonymous_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_LoginAnonymous_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_LoginAnonymous_Call) RunAndReturn(run func(context.Context, string) (*dto.User, error)) *MockUsers_LoginAnonymous_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockUsers) Update(ctx context.Context, body dto.UserUpdateRequest) (*dto.User, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.User + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) (*dto.User, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) *dto.User); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.User) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.UserUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockUsers_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockUsers_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.UserUpdateRequest +func (_e *MockUsers_Expecter) Update(ctx interface{}, body interface{}) *MockUsers_Update_Call { + return &MockUsers_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockUsers_Update_Call) Run(run func(ctx context.Context, body dto.UserUpdateRequest)) *MockUsers_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.UserUpdateRequest)) + }) + return _c +} + +func (_c *MockUsers_Update_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockUsers_Update_Call) RunAndReturn(run func(context.Context, dto.UserUpdateRequest) (*dto.User, error)) *MockUsers_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockUsers creates a new instance of MockUsers. 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 NewMockUsers(t interface { + mock.TestingT + Cleanup(func()) +}) *MockUsers { + mock := &MockUsers{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} 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 +} From cf0727af37843f402df4000cc451d2150fec7a64 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 15 Jan 2025 16:18:47 +0100 Subject: [PATCH 18/27] chore: generate only needed mocks and adapt readme for mockery --- server/README.md | 20 +- server/src/.mockery.yaml | 9 +- .../src/mocks/services/mock_BoardReactions.go | 74 --- .../src/mocks/services/mock_BoardTemplates.go | 608 ------------------ server/src/mocks/services/mock_Feedback.go | 130 ---- server/src/mocks/services/mock_Health.go | 122 ---- server/src/mocks/services/mock_Notes.go | 382 ----------- server/src/mocks/services/mock_Reactions.go | 328 ---------- server/src/mocks/services/mock_Users.go | 582 ----------------- server/src/mocks/services/mock_Votings.go | 443 ------------- 10 files changed, 24 insertions(+), 2674 deletions(-) delete mode 100644 server/src/mocks/services/mock_BoardReactions.go delete mode 100644 server/src/mocks/services/mock_BoardTemplates.go delete mode 100644 server/src/mocks/services/mock_Feedback.go delete mode 100644 server/src/mocks/services/mock_Health.go delete mode 100644 server/src/mocks/services/mock_Notes.go delete mode 100644 server/src/mocks/services/mock_Reactions.go delete mode 100644 server/src/mocks/services/mock_Users.go delete mode 100644 server/src/mocks/services/mock_Votings.go diff --git a/server/README.md b/server/README.md index b72c66ce6e..bb4427dbf9 100644 --- a/server/README.md +++ b/server/README.md @@ -23,7 +23,7 @@ can also be set by environment variables so you don't have to worry about the ru each time. ## Configuration via TOML file -You can also configure the server using a TOML file. To do this, pass the `--config` flag to the server executable, followed by the path to the TOML file. +You can also configure the server using a TOML file. To do this, pass the `--config` flag to the server executable, followed by the path to the TOML file. For example, to configure the server using a file named `config_example.toml`, you would run the following command: @@ -31,7 +31,7 @@ For example, to configure the server using a file named `config_example.toml`, y go run . --config config_example.toml ``` -To see all values that can be set and what purpose they serve, take a look at the provided `config_example.toml` file. +To see all values that can be set and what purpose they serve, take a look at the provided `config_example.toml` file. ## API @@ -41,3 +41,19 @@ resources and take a look at our documentation. Currently, you can also just open your browser on [http://localhost:8080](http://localhost:8080) to see our debug client. We'll disable it once everything got stable. + + +## Testing and Mockery + +At a certain point, it is more convenient to use a framework to generate mocks for interfaces. +This is where the use of Mockery comes into play (https://vektra.github.io/mockery/latest/installation/). +Depending on the operating system (macOS via Homebrew), +install Mockery and run it in the directory with .mockery.yaml (mockery). The mocks in the mocks directory will be automatically regenerated. + +```bash +# switch to src directory +# and just run mockery to refresh the mocks +mockery +``` + +Configuration of mockery is described in the .mockery.yaml file. diff --git a/server/src/.mockery.yaml b/server/src/.mockery.yaml index c26a0bf520..d8aca0eb11 100644 --- a/server/src/.mockery.yaml +++ b/server/src/.mockery.yaml @@ -8,6 +8,9 @@ issue-845-fix: true packages: # configuration on package level scrumlr.io/server/services: - config: - # generate for all interfaces in services a mock (for example: mock_Boards) - all: true + # configuration on interface level + interfaces: + Boards: + all: true + BoardSessions: + all: true diff --git a/server/src/mocks/services/mock_BoardReactions.go b/server/src/mocks/services/mock_BoardReactions.go deleted file mode 100644 index 0eee513361..0000000000 --- a/server/src/mocks/services/mock_BoardReactions.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockBoardReactions is an autogenerated mock type for the BoardReactions type -type MockBoardReactions struct { - mock.Mock -} - -type MockBoardReactions_Expecter struct { - mock *mock.Mock -} - -func (_m *MockBoardReactions) EXPECT() *MockBoardReactions_Expecter { - return &MockBoardReactions_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, board, body -func (_m *MockBoardReactions) Create(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest) { - _m.Called(ctx, board, body) -} - -// MockBoardReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockBoardReactions_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - body dto.BoardReactionCreateRequest -func (_e *MockBoardReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockBoardReactions_Create_Call { - return &MockBoardReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} -} - -func (_c *MockBoardReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.BoardReactionCreateRequest)) - }) - return _c -} - -func (_c *MockBoardReactions_Create_Call) Return() *MockBoardReactions_Create_Call { - _c.Call.Return() - return _c -} - -func (_c *MockBoardReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.BoardReactionCreateRequest)) *MockBoardReactions_Create_Call { - _c.Run(run) - return _c -} - -// NewMockBoardReactions creates a new instance of MockBoardReactions. 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 NewMockBoardReactions(t interface { - mock.TestingT - Cleanup(func()) -}) *MockBoardReactions { - mock := &MockBoardReactions{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_BoardTemplates.go b/server/src/mocks/services/mock_BoardTemplates.go deleted file mode 100644 index 5511784877..0000000000 --- a/server/src/mocks/services/mock_BoardTemplates.go +++ /dev/null @@ -1,608 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockBoardTemplates is an autogenerated mock type for the BoardTemplates type -type MockBoardTemplates struct { - mock.Mock -} - -type MockBoardTemplates_Expecter struct { - mock *mock.Mock -} - -func (_m *MockBoardTemplates) EXPECT() *MockBoardTemplates_Expecter { - return &MockBoardTemplates_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) Create(ctx context.Context, body dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *dto.BoardTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.CreateBoardTemplateRequest) *dto.BoardTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.BoardTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.CreateBoardTemplateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockBoardTemplates_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - body dto.CreateBoardTemplateRequest -func (_e *MockBoardTemplates_Expecter) Create(ctx interface{}, body interface{}) *MockBoardTemplates_Create_Call { - return &MockBoardTemplates_Create_Call{Call: _e.mock.On("Create", ctx, body)} -} - -func (_c *MockBoardTemplates_Create_Call) Run(run func(ctx context.Context, body dto.CreateBoardTemplateRequest)) *MockBoardTemplates_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.CreateBoardTemplateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_Create_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_Create_Call) RunAndReturn(run func(context.Context, dto.CreateBoardTemplateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Create_Call { - _c.Call.Return(run) - return _c -} - -// CreateColumnTemplate provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) CreateColumnTemplate(ctx context.Context, body dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for CreateColumnTemplate") - } - - var r0 *dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateRequest) *dto.ColumnTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.ColumnTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_CreateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateColumnTemplate' -type MockBoardTemplates_CreateColumnTemplate_Call struct { - *mock.Call -} - -// CreateColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - body dto.ColumnTemplateRequest -func (_e *MockBoardTemplates_Expecter) CreateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_CreateColumnTemplate_Call { - return &MockBoardTemplates_CreateColumnTemplate_Call{Call: _e.mock.On("CreateColumnTemplate", ctx, body)} -} - -func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateRequest)) *MockBoardTemplates_CreateColumnTemplate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.ColumnTemplateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_CreateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_CreateColumnTemplate_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_CreateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_CreateColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function with given fields: ctx, id -func (_m *MockBoardTemplates) Delete(ctx context.Context, id uuid.UUID) error { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) error); ok { - r0 = rf(ctx, id) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockBoardTemplates_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type MockBoardTemplates_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockBoardTemplates_Expecter) Delete(ctx interface{}, id interface{}) *MockBoardTemplates_Delete_Call { - return &MockBoardTemplates_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} -} - -func (_c *MockBoardTemplates_Delete_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_Delete_Call) Return(_a0 error) *MockBoardTemplates_Delete_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBoardTemplates_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID) error) *MockBoardTemplates_Delete_Call { - _c.Call.Return(run) - return _c -} - -// DeleteColumnTemplate provides a mock function with given fields: ctx, boar, column, user -func (_m *MockBoardTemplates) DeleteColumnTemplate(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID) error { - ret := _m.Called(ctx, boar, column, user) - - if len(ret) == 0 { - panic("no return value specified for DeleteColumnTemplate") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { - r0 = rf(ctx, boar, column, user) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockBoardTemplates_DeleteColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteColumnTemplate' -type MockBoardTemplates_DeleteColumnTemplate_Call struct { - *mock.Call -} - -// DeleteColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - boar uuid.UUID -// - column uuid.UUID -// - user uuid.UUID -func (_e *MockBoardTemplates_Expecter) DeleteColumnTemplate(ctx interface{}, boar interface{}, column interface{}, user interface{}) *MockBoardTemplates_DeleteColumnTemplate_Call { - return &MockBoardTemplates_DeleteColumnTemplate_Call{Call: _e.mock.On("DeleteColumnTemplate", ctx, boar, column, user)} -} - -func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Run(run func(ctx context.Context, boar uuid.UUID, column uuid.UUID, user uuid.UUID)) *MockBoardTemplates_DeleteColumnTemplate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) Return(_a0 error) *MockBoardTemplates_DeleteColumnTemplate_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockBoardTemplates_DeleteColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockBoardTemplates_DeleteColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockBoardTemplates) Get(ctx context.Context, id uuid.UUID) (*dto.BoardTemplate, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.BoardTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.BoardTemplate); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.BoardTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockBoardTemplates_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockBoardTemplates_Expecter) Get(ctx interface{}, id interface{}) *MockBoardTemplates_Get_Call { - return &MockBoardTemplates_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockBoardTemplates_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockBoardTemplates_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_Get_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.BoardTemplate, error)) *MockBoardTemplates_Get_Call { - _c.Call.Return(run) - return _c -} - -// GetColumnTemplate provides a mock function with given fields: ctx, boardID, columnID -func (_m *MockBoardTemplates) GetColumnTemplate(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, boardID, columnID) - - if len(ret) == 0 { - panic("no return value specified for GetColumnTemplate") - } - - var r0 *dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)); ok { - return rf(ctx, boardID, columnID) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.ColumnTemplate); ok { - r0 = rf(ctx, boardID, columnID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.ColumnTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID) error); ok { - r1 = rf(ctx, boardID, columnID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_GetColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetColumnTemplate' -type MockBoardTemplates_GetColumnTemplate_Call struct { - *mock.Call -} - -// GetColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - boardID uuid.UUID -// - columnID uuid.UUID -func (_e *MockBoardTemplates_Expecter) GetColumnTemplate(ctx interface{}, boardID interface{}, columnID interface{}) *MockBoardTemplates_GetColumnTemplate_Call { - return &MockBoardTemplates_GetColumnTemplate_Call{Call: _e.mock.On("GetColumnTemplate", ctx, boardID, columnID)} -} - -func (_c *MockBoardTemplates_GetColumnTemplate_Call) Run(run func(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID)) *MockBoardTemplates_GetColumnTemplate_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 *MockBoardTemplates_GetColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_GetColumnTemplate_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_GetColumnTemplate_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.ColumnTemplate, error)) *MockBoardTemplates_GetColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function with given fields: ctx, user -func (_m *MockBoardTemplates) List(ctx context.Context, user uuid.UUID) ([]*dto.BoardTemplateFull, error) { - ret := _m.Called(ctx, user) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*dto.BoardTemplateFull - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)); ok { - return rf(ctx, user) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.BoardTemplateFull); ok { - r0 = rf(ctx, user) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.BoardTemplateFull) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, user) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockBoardTemplates_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - user uuid.UUID -func (_e *MockBoardTemplates_Expecter) List(ctx interface{}, user interface{}) *MockBoardTemplates_List_Call { - return &MockBoardTemplates_List_Call{Call: _e.mock.On("List", ctx, user)} -} - -func (_c *MockBoardTemplates_List_Call) Run(run func(ctx context.Context, user uuid.UUID)) *MockBoardTemplates_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_List_Call) Return(_a0 []*dto.BoardTemplateFull, _a1 error) *MockBoardTemplates_List_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.BoardTemplateFull, error)) *MockBoardTemplates_List_Call { - _c.Call.Return(run) - return _c -} - -// ListColumnTemplates provides a mock function with given fields: ctx, board -func (_m *MockBoardTemplates) ListColumnTemplates(ctx context.Context, board uuid.UUID) ([]*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, board) - - if len(ret) == 0 { - panic("no return value specified for ListColumnTemplates") - } - - var r0 []*dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)); ok { - return rf(ctx, board) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.ColumnTemplate); ok { - r0 = rf(ctx, board) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.ColumnTemplate) - } - } - - 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 -} - -// MockBoardTemplates_ListColumnTemplates_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListColumnTemplates' -type MockBoardTemplates_ListColumnTemplates_Call struct { - *mock.Call -} - -// ListColumnTemplates is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -func (_e *MockBoardTemplates_Expecter) ListColumnTemplates(ctx interface{}, board interface{}) *MockBoardTemplates_ListColumnTemplates_Call { - return &MockBoardTemplates_ListColumnTemplates_Call{Call: _e.mock.On("ListColumnTemplates", ctx, board)} -} - -func (_c *MockBoardTemplates_ListColumnTemplates_Call) Run(run func(ctx context.Context, board uuid.UUID)) *MockBoardTemplates_ListColumnTemplates_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockBoardTemplates_ListColumnTemplates_Call) Return(_a0 []*dto.ColumnTemplate, _a1 error) *MockBoardTemplates_ListColumnTemplates_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_ListColumnTemplates_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.ColumnTemplate, error)) *MockBoardTemplates_ListColumnTemplates_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) Update(ctx context.Context, body dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.BoardTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.BoardTemplateUpdateRequest) *dto.BoardTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.BoardTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.BoardTemplateUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockBoardTemplates_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - body dto.BoardTemplateUpdateRequest -func (_e *MockBoardTemplates_Expecter) Update(ctx interface{}, body interface{}) *MockBoardTemplates_Update_Call { - return &MockBoardTemplates_Update_Call{Call: _e.mock.On("Update", ctx, body)} -} - -func (_c *MockBoardTemplates_Update_Call) Run(run func(ctx context.Context, body dto.BoardTemplateUpdateRequest)) *MockBoardTemplates_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.BoardTemplateUpdateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_Update_Call) Return(_a0 *dto.BoardTemplate, _a1 error) *MockBoardTemplates_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_Update_Call) RunAndReturn(run func(context.Context, dto.BoardTemplateUpdateRequest) (*dto.BoardTemplate, error)) *MockBoardTemplates_Update_Call { - _c.Call.Return(run) - return _c -} - -// UpdateColumnTemplate provides a mock function with given fields: ctx, body -func (_m *MockBoardTemplates) UpdateColumnTemplate(ctx context.Context, body dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for UpdateColumnTemplate") - } - - var r0 *dto.ColumnTemplate - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnTemplateUpdateRequest) *dto.ColumnTemplate); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.ColumnTemplate) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.ColumnTemplateUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockBoardTemplates_UpdateColumnTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateColumnTemplate' -type MockBoardTemplates_UpdateColumnTemplate_Call struct { - *mock.Call -} - -// UpdateColumnTemplate is a helper method to define mock.On call -// - ctx context.Context -// - body dto.ColumnTemplateUpdateRequest -func (_e *MockBoardTemplates_Expecter) UpdateColumnTemplate(ctx interface{}, body interface{}) *MockBoardTemplates_UpdateColumnTemplate_Call { - return &MockBoardTemplates_UpdateColumnTemplate_Call{Call: _e.mock.On("UpdateColumnTemplate", ctx, body)} -} - -func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Run(run func(ctx context.Context, body dto.ColumnTemplateUpdateRequest)) *MockBoardTemplates_UpdateColumnTemplate_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.ColumnTemplateUpdateRequest)) - }) - return _c -} - -func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) Return(_a0 *dto.ColumnTemplate, _a1 error) *MockBoardTemplates_UpdateColumnTemplate_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockBoardTemplates_UpdateColumnTemplate_Call) RunAndReturn(run func(context.Context, dto.ColumnTemplateUpdateRequest) (*dto.ColumnTemplate, error)) *MockBoardTemplates_UpdateColumnTemplate_Call { - _c.Call.Return(run) - return _c -} - -// NewMockBoardTemplates creates a new instance of MockBoardTemplates. 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 NewMockBoardTemplates(t interface { - mock.TestingT - Cleanup(func()) -}) *MockBoardTemplates { - mock := &MockBoardTemplates{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Feedback.go b/server/src/mocks/services/mock_Feedback.go deleted file mode 100644 index 1af1cc0bde..0000000000 --- a/server/src/mocks/services/mock_Feedback.go +++ /dev/null @@ -1,130 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// MockFeedback is an autogenerated mock type for the Feedback type -type MockFeedback struct { - mock.Mock -} - -type MockFeedback_Expecter struct { - mock *mock.Mock -} - -func (_m *MockFeedback) EXPECT() *MockFeedback_Expecter { - return &MockFeedback_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, feedbackType, contact, text -func (_m *MockFeedback) Create(ctx context.Context, feedbackType string, contact string, text string) error { - ret := _m.Called(ctx, feedbackType, contact, text) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok { - r0 = rf(ctx, feedbackType, contact, text) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockFeedback_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockFeedback_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - feedbackType string -// - contact string -// - text string -func (_e *MockFeedback_Expecter) Create(ctx interface{}, feedbackType interface{}, contact interface{}, text interface{}) *MockFeedback_Create_Call { - return &MockFeedback_Create_Call{Call: _e.mock.On("Create", ctx, feedbackType, contact, text)} -} - -func (_c *MockFeedback_Create_Call) Run(run func(ctx context.Context, feedbackType string, contact string, text string)) *MockFeedback_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockFeedback_Create_Call) Return(_a0 error) *MockFeedback_Create_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFeedback_Create_Call) RunAndReturn(run func(context.Context, string, string, string) error) *MockFeedback_Create_Call { - _c.Call.Return(run) - return _c -} - -// Enabled provides a mock function with no fields -func (_m *MockFeedback) Enabled() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Enabled") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockFeedback_Enabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Enabled' -type MockFeedback_Enabled_Call struct { - *mock.Call -} - -// Enabled is a helper method to define mock.On call -func (_e *MockFeedback_Expecter) Enabled() *MockFeedback_Enabled_Call { - return &MockFeedback_Enabled_Call{Call: _e.mock.On("Enabled")} -} - -func (_c *MockFeedback_Enabled_Call) Run(run func()) *MockFeedback_Enabled_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockFeedback_Enabled_Call) Return(_a0 bool) *MockFeedback_Enabled_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockFeedback_Enabled_Call) RunAndReturn(run func() bool) *MockFeedback_Enabled_Call { - _c.Call.Return(run) - return _c -} - -// NewMockFeedback creates a new instance of MockFeedback. 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 NewMockFeedback(t interface { - mock.TestingT - Cleanup(func()) -}) *MockFeedback { - mock := &MockFeedback{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Health.go b/server/src/mocks/services/mock_Health.go deleted file mode 100644 index 8f4882aa7b..0000000000 --- a/server/src/mocks/services/mock_Health.go +++ /dev/null @@ -1,122 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import mock "github.com/stretchr/testify/mock" - -// MockHealth is an autogenerated mock type for the Health type -type MockHealth struct { - mock.Mock -} - -type MockHealth_Expecter struct { - mock *mock.Mock -} - -func (_m *MockHealth) EXPECT() *MockHealth_Expecter { - return &MockHealth_Expecter{mock: &_m.Mock} -} - -// IsDatabaseHealthy provides a mock function with no fields -func (_m *MockHealth) IsDatabaseHealthy() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsDatabaseHealthy") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockHealth_IsDatabaseHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsDatabaseHealthy' -type MockHealth_IsDatabaseHealthy_Call struct { - *mock.Call -} - -// IsDatabaseHealthy is a helper method to define mock.On call -func (_e *MockHealth_Expecter) IsDatabaseHealthy() *MockHealth_IsDatabaseHealthy_Call { - return &MockHealth_IsDatabaseHealthy_Call{Call: _e.mock.On("IsDatabaseHealthy")} -} - -func (_c *MockHealth_IsDatabaseHealthy_Call) Run(run func()) *MockHealth_IsDatabaseHealthy_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockHealth_IsDatabaseHealthy_Call) Return(_a0 bool) *MockHealth_IsDatabaseHealthy_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockHealth_IsDatabaseHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsDatabaseHealthy_Call { - _c.Call.Return(run) - return _c -} - -// IsRealtimeHealthy provides a mock function with no fields -func (_m *MockHealth) IsRealtimeHealthy() bool { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for IsRealtimeHealthy") - } - - var r0 bool - if rf, ok := ret.Get(0).(func() bool); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(bool) - } - - return r0 -} - -// MockHealth_IsRealtimeHealthy_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRealtimeHealthy' -type MockHealth_IsRealtimeHealthy_Call struct { - *mock.Call -} - -// IsRealtimeHealthy is a helper method to define mock.On call -func (_e *MockHealth_Expecter) IsRealtimeHealthy() *MockHealth_IsRealtimeHealthy_Call { - return &MockHealth_IsRealtimeHealthy_Call{Call: _e.mock.On("IsRealtimeHealthy")} -} - -func (_c *MockHealth_IsRealtimeHealthy_Call) Run(run func()) *MockHealth_IsRealtimeHealthy_Call { - _c.Call.Run(func(args mock.Arguments) { - run() - }) - return _c -} - -func (_c *MockHealth_IsRealtimeHealthy_Call) Return(_a0 bool) *MockHealth_IsRealtimeHealthy_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockHealth_IsRealtimeHealthy_Call) RunAndReturn(run func() bool) *MockHealth_IsRealtimeHealthy_Call { - _c.Call.Return(run) - return _c -} - -// NewMockHealth creates a new instance of MockHealth. 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 NewMockHealth(t interface { - mock.TestingT - Cleanup(func()) -}) *MockHealth { - mock := &MockHealth{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Notes.go b/server/src/mocks/services/mock_Notes.go deleted file mode 100644 index 66024de389..0000000000 --- a/server/src/mocks/services/mock_Notes.go +++ /dev/null @@ -1,382 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockNotes is an autogenerated mock type for the Notes type -type MockNotes struct { - mock.Mock -} - -type MockNotes_Expecter struct { - mock *mock.Mock -} - -func (_m *MockNotes) EXPECT() *MockNotes_Expecter { - return &MockNotes_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, body -func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*dto.Note, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *dto.Note); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.NoteCreateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockNotes_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteCreateRequest -func (_e *MockNotes_Expecter) Create(ctx interface{}, body interface{}) *MockNotes_Create_Call { - return &MockNotes_Create_Call{Call: _e.mock.On("Create", ctx, body)} -} - -func (_c *MockNotes_Create_Call) Run(run func(ctx context.Context, body dto.NoteCreateRequest)) *MockNotes_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteCreateRequest)) - }) - return _c -} - -func (_c *MockNotes_Create_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)) *MockNotes_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function with given fields: ctx, body, id -func (_m *MockNotes) Delete(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID) error { - ret := _m.Called(ctx, body, id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error); ok { - r0 = rf(ctx, body, id) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockNotes_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type MockNotes_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteDeleteRequest -// - id uuid.UUID -func (_e *MockNotes_Expecter) Delete(ctx interface{}, body interface{}, id interface{}) *MockNotes_Delete_Call { - return &MockNotes_Delete_Call{Call: _e.mock.On("Delete", ctx, body, id)} -} - -func (_c *MockNotes_Delete_Call) Run(run func(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID)) *MockNotes_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteDeleteRequest), args[2].(uuid.UUID)) - }) - return _c -} - -func (_c *MockNotes_Delete_Call) Return(_a0 error) *MockNotes_Delete_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockNotes_Delete_Call) RunAndReturn(run func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error) *MockNotes_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Note, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Note); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockNotes_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockNotes_Expecter) Get(ctx interface{}, id interface{}) *MockNotes_Get_Call { - return &MockNotes_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockNotes_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockNotes_Get_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Note, error)) *MockNotes_Get_Call { - _c.Call.Return(run) - return _c -} - -// Import provides a mock function with given fields: ctx, body -func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*dto.Note, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Import") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*dto.Note, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *dto.Note); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.NoteImportRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Import_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Import' -type MockNotes_Import_Call struct { - *mock.Call -} - -// Import is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteImportRequest -func (_e *MockNotes_Expecter) Import(ctx interface{}, body interface{}) *MockNotes_Import_Call { - return &MockNotes_Import_Call{Call: _e.mock.On("Import", ctx, body)} -} - -func (_c *MockNotes_Import_Call) Run(run func(ctx context.Context, body dto.NoteImportRequest)) *MockNotes_Import_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteImportRequest)) - }) - return _c -} - -func (_c *MockNotes_Import_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Import_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*dto.Note, error)) *MockNotes_Import_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function with given fields: ctx, id -func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*dto.Note, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Note, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Note); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockNotes_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockNotes_Expecter) List(ctx interface{}, id interface{}) *MockNotes_List_Call { - return &MockNotes_List_Call{Call: _e.mock.On("List", ctx, id)} -} - -func (_c *MockNotes_List_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockNotes_List_Call) Return(_a0 []*dto.Note, _a1 error) *MockNotes_List_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Note, error)) *MockNotes_List_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, body -func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*dto.Note, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.Note - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *dto.Note); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.NoteUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockNotes_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockNotes_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - body dto.NoteUpdateRequest -func (_e *MockNotes_Expecter) Update(ctx interface{}, body interface{}) *MockNotes_Update_Call { - return &MockNotes_Update_Call{Call: _e.mock.On("Update", ctx, body)} -} - -func (_c *MockNotes_Update_Call) Run(run func(ctx context.Context, body dto.NoteUpdateRequest)) *MockNotes_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.NoteUpdateRequest)) - }) - return _c -} - -func (_c *MockNotes_Update_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)) *MockNotes_Update_Call { - _c.Call.Return(run) - return _c -} - -// NewMockNotes creates a new instance of MockNotes. 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 NewMockNotes(t interface { - mock.TestingT - Cleanup(func()) -}) *MockNotes { - mock := &MockNotes{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Reactions.go b/server/src/mocks/services/mock_Reactions.go deleted file mode 100644 index d798028a82..0000000000 --- a/server/src/mocks/services/mock_Reactions.go +++ /dev/null @@ -1,328 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockReactions is an autogenerated mock type for the Reactions type -type MockReactions struct { - mock.Mock -} - -type MockReactions_Expecter struct { - mock *mock.Mock -} - -func (_m *MockReactions) EXPECT() *MockReactions_Expecter { - return &MockReactions_Expecter{mock: &_m.Mock} -} - -// Create provides a mock function with given fields: ctx, board, body -func (_m *MockReactions) Create(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest) (*dto.Reaction, error) { - ret := _m.Called(ctx, board, body) - - if len(ret) == 0 { - panic("no return value specified for Create") - } - - var r0 *dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)); ok { - return rf(ctx, board, body) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) *dto.Reaction); ok { - r0 = rf(ctx, board, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, dto.ReactionCreateRequest) error); ok { - r1 = rf(ctx, board, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' -type MockReactions_Create_Call struct { - *mock.Call -} - -// Create is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - body dto.ReactionCreateRequest -func (_e *MockReactions_Expecter) Create(ctx interface{}, board interface{}, body interface{}) *MockReactions_Create_Call { - return &MockReactions_Create_Call{Call: _e.mock.On("Create", ctx, board, body)} -} - -func (_c *MockReactions_Create_Call) Run(run func(ctx context.Context, board uuid.UUID, body dto.ReactionCreateRequest)) *MockReactions_Create_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(dto.ReactionCreateRequest)) - }) - return _c -} - -func (_c *MockReactions_Create_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Create_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_Create_Call) RunAndReturn(run func(context.Context, uuid.UUID, dto.ReactionCreateRequest) (*dto.Reaction, error)) *MockReactions_Create_Call { - _c.Call.Return(run) - return _c -} - -// Delete provides a mock function with given fields: ctx, board, user, id -func (_m *MockReactions) Delete(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID) error { - ret := _m.Called(ctx, board, user, id) - - if len(ret) == 0 { - panic("no return value specified for Delete") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error); ok { - r0 = rf(ctx, board, user, id) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// MockReactions_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' -type MockReactions_Delete_Call struct { - *mock.Call -} - -// Delete is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - user uuid.UUID -// - id uuid.UUID -func (_e *MockReactions_Expecter) Delete(ctx interface{}, board interface{}, user interface{}, id interface{}) *MockReactions_Delete_Call { - return &MockReactions_Delete_Call{Call: _e.mock.On("Delete", ctx, board, user, id)} -} - -func (_c *MockReactions_Delete_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID)) *MockReactions_Delete_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID)) - }) - return _c -} - -func (_c *MockReactions_Delete_Call) Return(_a0 error) *MockReactions_Delete_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *MockReactions_Delete_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID) error) *MockReactions_Delete_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockReactions) Get(ctx context.Context, id uuid.UUID) (*dto.Reaction, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Reaction, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Reaction); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockReactions_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockReactions_Expecter) Get(ctx interface{}, id interface{}) *MockReactions_Get_Call { - return &MockReactions_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockReactions_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockReactions_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockReactions_Get_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Reaction, error)) *MockReactions_Get_Call { - _c.Call.Return(run) - return _c -} - -// List provides a mock function with given fields: ctx, boardID -func (_m *MockReactions) List(ctx context.Context, boardID uuid.UUID) ([]*dto.Reaction, error) { - ret := _m.Called(ctx, boardID) - - if len(ret) == 0 { - panic("no return value specified for List") - } - - var r0 []*dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Reaction, error)); ok { - return rf(ctx, boardID) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Reaction); ok { - r0 = rf(ctx, boardID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, boardID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' -type MockReactions_List_Call struct { - *mock.Call -} - -// List is a helper method to define mock.On call -// - ctx context.Context -// - boardID uuid.UUID -func (_e *MockReactions_Expecter) List(ctx interface{}, boardID interface{}) *MockReactions_List_Call { - return &MockReactions_List_Call{Call: _e.mock.On("List", ctx, boardID)} -} - -func (_c *MockReactions_List_Call) Run(run func(ctx context.Context, boardID uuid.UUID)) *MockReactions_List_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockReactions_List_Call) Return(_a0 []*dto.Reaction, _a1 error) *MockReactions_List_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Reaction, error)) *MockReactions_List_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, board, user, id, body -func (_m *MockReactions) Update(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest) (*dto.Reaction, error) { - ret := _m.Called(ctx, board, user, id, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.Reaction - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)); ok { - return rf(ctx, board, user, id, body) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) *dto.Reaction); ok { - r0 = rf(ctx, board, user, id, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Reaction) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) error); ok { - r1 = rf(ctx, board, user, id, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockReactions_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockReactions_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - board uuid.UUID -// - user uuid.UUID -// - id uuid.UUID -// - body dto.ReactionUpdateTypeRequest -func (_e *MockReactions_Expecter) Update(ctx interface{}, board interface{}, user interface{}, id interface{}, body interface{}) *MockReactions_Update_Call { - return &MockReactions_Update_Call{Call: _e.mock.On("Update", ctx, board, user, id, body)} -} - -func (_c *MockReactions_Update_Call) Run(run func(ctx context.Context, board uuid.UUID, user uuid.UUID, id uuid.UUID, body dto.ReactionUpdateTypeRequest)) *MockReactions_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID), args[2].(uuid.UUID), args[3].(uuid.UUID), args[4].(dto.ReactionUpdateTypeRequest)) - }) - return _c -} - -func (_c *MockReactions_Update_Call) Return(_a0 *dto.Reaction, _a1 error) *MockReactions_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockReactions_Update_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID, uuid.UUID, dto.ReactionUpdateTypeRequest) (*dto.Reaction, error)) *MockReactions_Update_Call { - _c.Call.Return(run) - return _c -} - -// NewMockReactions creates a new instance of MockReactions. 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 NewMockReactions(t interface { - mock.TestingT - Cleanup(func()) -}) *MockReactions { - mock := &MockReactions{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Users.go b/server/src/mocks/services/mock_Users.go deleted file mode 100644 index e5e9855981..0000000000 --- a/server/src/mocks/services/mock_Users.go +++ /dev/null @@ -1,582 +0,0 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. - -package services - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - dto "scrumlr.io/server/common/dto" - - uuid "github.com/google/uuid" -) - -// MockUsers is an autogenerated mock type for the Users type -type MockUsers struct { - mock.Mock -} - -type MockUsers_Expecter struct { - mock *mock.Mock -} - -func (_m *MockUsers) EXPECT() *MockUsers_Expecter { - return &MockUsers_Expecter{mock: &_m.Mock} -} - -// CreateAppleUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateAppleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateAppleUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateAppleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAppleUser' -type MockUsers_CreateAppleUser_Call struct { - *mock.Call -} - -// CreateAppleUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateAppleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAppleUser_Call { - return &MockUsers_CreateAppleUser_Call{Call: _e.mock.On("CreateAppleUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateAppleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAppleUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateAppleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAppleUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateAppleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAppleUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateAzureAdUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateAzureAdUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateAzureAdUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateAzureAdUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAzureAdUser' -type MockUsers_CreateAzureAdUser_Call struct { - *mock.Call -} - -// CreateAzureAdUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateAzureAdUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateAzureAdUser_Call { - return &MockUsers_CreateAzureAdUser_Call{Call: _e.mock.On("CreateAzureAdUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateAzureAdUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateAzureAdUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateAzureAdUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateAzureAdUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateAzureAdUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateAzureAdUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateGitHubUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateGitHubUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateGitHubUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateGitHubUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGitHubUser' -type MockUsers_CreateGitHubUser_Call struct { - *mock.Call -} - -// CreateGitHubUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateGitHubUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGitHubUser_Call { - return &MockUsers_CreateGitHubUser_Call{Call: _e.mock.On("CreateGitHubUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateGitHubUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGitHubUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateGitHubUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGitHubUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateGitHubUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGitHubUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateGoogleUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateGoogleUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateGoogleUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateGoogleUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateGoogleUser' -type MockUsers_CreateGoogleUser_Call struct { - *mock.Call -} - -// CreateGoogleUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateGoogleUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateGoogleUser_Call { - return &MockUsers_CreateGoogleUser_Call{Call: _e.mock.On("CreateGoogleUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateGoogleUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateGoogleUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateGoogleUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateGoogleUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateGoogleUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateGoogleUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateMicrosoftUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateMicrosoftUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateMicrosoftUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateMicrosoftUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMicrosoftUser' -type MockUsers_CreateMicrosoftUser_Call struct { - *mock.Call -} - -// CreateMicrosoftUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateMicrosoftUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateMicrosoftUser_Call { - return &MockUsers_CreateMicrosoftUser_Call{Call: _e.mock.On("CreateMicrosoftUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateMicrosoftUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateMicrosoftUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateMicrosoftUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateMicrosoftUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateMicrosoftUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateMicrosoftUser_Call { - _c.Call.Return(run) - return _c -} - -// CreateOIDCUser provides a mock function with given fields: ctx, id, name, avatarUrl -func (_m *MockUsers) CreateOIDCUser(ctx context.Context, id string, name string, avatarUrl string) (*dto.User, error) { - ret := _m.Called(ctx, id, name, avatarUrl) - - if len(ret) == 0 { - panic("no return value specified for CreateOIDCUser") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (*dto.User, error)); ok { - return rf(ctx, id, name, avatarUrl) - } - if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *dto.User); ok { - r0 = rf(ctx, id, name, avatarUrl) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { - r1 = rf(ctx, id, name, avatarUrl) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_CreateOIDCUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOIDCUser' -type MockUsers_CreateOIDCUser_Call struct { - *mock.Call -} - -// CreateOIDCUser is a helper method to define mock.On call -// - ctx context.Context -// - id string -// - name string -// - avatarUrl string -func (_e *MockUsers_Expecter) CreateOIDCUser(ctx interface{}, id interface{}, name interface{}, avatarUrl interface{}) *MockUsers_CreateOIDCUser_Call { - return &MockUsers_CreateOIDCUser_Call{Call: _e.mock.On("CreateOIDCUser", ctx, id, name, avatarUrl)} -} - -func (_c *MockUsers_CreateOIDCUser_Call) Run(run func(ctx context.Context, id string, name string, avatarUrl string)) *MockUsers_CreateOIDCUser_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) - }) - return _c -} - -func (_c *MockUsers_CreateOIDCUser_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_CreateOIDCUser_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_CreateOIDCUser_Call) RunAndReturn(run func(context.Context, string, string, string) (*dto.User, error)) *MockUsers_CreateOIDCUser_Call { - _c.Call.Return(run) - return _c -} - -// Get provides a mock function with given fields: ctx, id -func (_m *MockUsers) Get(ctx context.Context, id uuid.UUID) (*dto.User, error) { - ret := _m.Called(ctx, id) - - if len(ret) == 0 { - panic("no return value specified for Get") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.User, error)); ok { - return rf(ctx, id) - } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.User); ok { - r0 = rf(ctx, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { - r1 = rf(ctx, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' -type MockUsers_Get_Call struct { - *mock.Call -} - -// Get is a helper method to define mock.On call -// - ctx context.Context -// - id uuid.UUID -func (_e *MockUsers_Expecter) Get(ctx interface{}, id interface{}) *MockUsers_Get_Call { - return &MockUsers_Get_Call{Call: _e.mock.On("Get", ctx, id)} -} - -func (_c *MockUsers_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockUsers_Get_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uuid.UUID)) - }) - return _c -} - -func (_c *MockUsers_Get_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Get_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.User, error)) *MockUsers_Get_Call { - _c.Call.Return(run) - return _c -} - -// LoginAnonymous provides a mock function with given fields: ctx, name -func (_m *MockUsers) LoginAnonymous(ctx context.Context, name string) (*dto.User, error) { - ret := _m.Called(ctx, name) - - if len(ret) == 0 { - panic("no return value specified for LoginAnonymous") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*dto.User, error)); ok { - return rf(ctx, name) - } - if rf, ok := ret.Get(0).(func(context.Context, string) *dto.User); ok { - r0 = rf(ctx, name) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { - r1 = rf(ctx, name) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_LoginAnonymous_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoginAnonymous' -type MockUsers_LoginAnonymous_Call struct { - *mock.Call -} - -// LoginAnonymous is a helper method to define mock.On call -// - ctx context.Context -// - name string -func (_e *MockUsers_Expecter) LoginAnonymous(ctx interface{}, name interface{}) *MockUsers_LoginAnonymous_Call { - return &MockUsers_LoginAnonymous_Call{Call: _e.mock.On("LoginAnonymous", ctx, name)} -} - -func (_c *MockUsers_LoginAnonymous_Call) Run(run func(ctx context.Context, name string)) *MockUsers_LoginAnonymous_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string)) - }) - return _c -} - -func (_c *MockUsers_LoginAnonymous_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_LoginAnonymous_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_LoginAnonymous_Call) RunAndReturn(run func(context.Context, string) (*dto.User, error)) *MockUsers_LoginAnonymous_Call { - _c.Call.Return(run) - return _c -} - -// Update provides a mock function with given fields: ctx, body -func (_m *MockUsers) Update(ctx context.Context, body dto.UserUpdateRequest) (*dto.User, error) { - ret := _m.Called(ctx, body) - - if len(ret) == 0 { - panic("no return value specified for Update") - } - - var r0 *dto.User - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) (*dto.User, error)); ok { - return rf(ctx, body) - } - if rf, ok := ret.Get(0).(func(context.Context, dto.UserUpdateRequest) *dto.User); ok { - r0 = rf(ctx, body) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.User) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, dto.UserUpdateRequest) error); ok { - r1 = rf(ctx, body) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// MockUsers_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' -type MockUsers_Update_Call struct { - *mock.Call -} - -// Update is a helper method to define mock.On call -// - ctx context.Context -// - body dto.UserUpdateRequest -func (_e *MockUsers_Expecter) Update(ctx interface{}, body interface{}) *MockUsers_Update_Call { - return &MockUsers_Update_Call{Call: _e.mock.On("Update", ctx, body)} -} - -func (_c *MockUsers_Update_Call) Run(run func(ctx context.Context, body dto.UserUpdateRequest)) *MockUsers_Update_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.UserUpdateRequest)) - }) - return _c -} - -func (_c *MockUsers_Update_Call) Return(_a0 *dto.User, _a1 error) *MockUsers_Update_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *MockUsers_Update_Call) RunAndReturn(run func(context.Context, dto.UserUpdateRequest) (*dto.User, error)) *MockUsers_Update_Call { - _c.Call.Return(run) - return _c -} - -// NewMockUsers creates a new instance of MockUsers. 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 NewMockUsers(t interface { - mock.TestingT - Cleanup(func()) -}) *MockUsers { - mock := &MockUsers{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/server/src/mocks/services/mock_Votings.go b/server/src/mocks/services/mock_Votings.go deleted file mode 100644 index 0d0a5d69be..0000000000 --- a/server/src/mocks/services/mock_Votings.go +++ /dev/null @@ -1,443 +0,0 @@ -// 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 -} From 1f8b1f35bb19bca81eb3cf2a5c785c9aae6c82db Mon Sep 17 00:00:00 2001 From: wschoepke Date: Thu, 16 Jan 2025 13:38:14 +0100 Subject: [PATCH 19/27] refactor: replace test content structure with TestParameterBundle usage in columns test --- server/src/api/columns_test.go | 156 +++++++++++---------------------- 1 file changed, 50 insertions(+), 106 deletions(-) diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go index cfac8cf8f0..cf4ca46287 100644 --- a/server/src/api/columns_test.go +++ b/server/src/api/columns_test.go @@ -25,28 +25,17 @@ func TestColumnTestSuite(t *testing.T) { } func (suite *ColumnTestSuite) TestCreateColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful created column", - expectedCode: http.StatusCreated, - }, - { - name: "Failed creating column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not create column", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful created column", http.StatusCreated, nil, false, false, nil). + Append("Failed creating column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -89,28 +78,16 @@ func (suite *ColumnTestSuite) TestCreateColumn() { } func (suite *ColumnTestSuite) TestDeleteColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful deleted column", - expectedCode: http.StatusNoContent, - }, - { - name: "Failed deleting column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not delete column", - }, - }, - } - - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful deleted column", http.StatusNoContent, nil, false, false, nil). + Append("Failed deleting column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -136,28 +113,17 @@ func (suite *ColumnTestSuite) TestDeleteColumn() { } func (suite *ColumnTestSuite) TestUpdateColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful updated column", - expectedCode: http.StatusOK, - }, - { - name: "Failed updating column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not update column", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful updated column", http.StatusOK, nil, false, false, nil). + Append("Failed updating column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -201,28 +167,17 @@ func (suite *ColumnTestSuite) TestUpdateColumn() { } func (suite *ColumnTestSuite) TestGetColumn() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful get column", - expectedCode: http.StatusOK, - }, - { - name: "Failed getting column", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not get column", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful get column", http.StatusOK, nil, false, false, nil). + Append("Failed getting column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get column", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) @@ -260,28 +215,17 @@ func (suite *ColumnTestSuite) TestGetColumn() { } func (suite *ColumnTestSuite) TestGetColumns() { - tests := []struct { - name string - expectedCode int - err error - }{ - { - name: "Successful get columns", - expectedCode: http.StatusOK, - }, - { - name: "Failed getting columns", - expectedCode: http.StatusInternalServerError, - err: &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not get columns", - }, - }, - } - for _, tt := range tests { + testParameterBundles := *TestParameterBundles{}. + Append("Successful get columns", http.StatusOK, nil, false, false, nil). + Append("Failed getting columns", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get columns", + }, false, false, nil) + + for _, tt := range testParameterBundles { suite.Run(tt.name, func() { s := new(Server) boardMock := services.NewMockBoards(suite.T()) From 289a481f8b4a8bdf0fa5a032ffd27f931ca03af7 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Thu, 16 Jan 2025 13:39:03 +0100 Subject: [PATCH 20/27] refactor: remove commented code --- server/src/api/json_parse_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/src/api/json_parse_test.go b/server/src/api/json_parse_test.go index f93888dd54..5321fbfbe5 100644 --- a/server/src/api/json_parse_test.go +++ b/server/src/api/json_parse_test.go @@ -80,9 +80,6 @@ func (suite *JSONErrTestSuite) TestJSONErrs() { suite.Run(tt.name, func() { s := new(Server) - //loggerConfig := zap.NewNop() // Use a no-op logger for testing - //_logger := loggerConfig.Sugar() - mockUUID := uuid.New() req := NewTestRequestBuilder("POST", "/", strings.NewReader(`{ "id": %s From 8a44a890359d2bb1620478431185cac0adf61180 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Thu, 16 Jan 2025 14:50:49 +0100 Subject: [PATCH 21/27] refactor: refactor notes tests with mockery mocks --- server/src/.mockery.yaml | 2 + server/src/api/notes_test.go | 195 +++--------- server/src/mocks/services/mock_Notes.go | 382 ++++++++++++++++++++++++ 3 files changed, 425 insertions(+), 154 deletions(-) create mode 100644 server/src/mocks/services/mock_Notes.go diff --git a/server/src/.mockery.yaml b/server/src/.mockery.yaml index d8aca0eb11..75bec072d4 100644 --- a/server/src/.mockery.yaml +++ b/server/src/.mockery.yaml @@ -14,3 +14,5 @@ packages: all: true BoardSessions: all: true + Notes: + all: true diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index 8f371fb880..2916e5c4dd 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -1,7 +1,6 @@ package api import ( - "context" "errors" "fmt" "github.com/go-chi/chi/v5" @@ -12,124 +11,13 @@ import ( "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/notes" - "scrumlr.io/server/services" + "scrumlr.io/server/mocks/services" "strings" "testing" ) -type NotesMock struct { - services.Notes - mock.Mock -} - -func (m *NotesMock) Create(ctx context.Context, req dto.NoteCreateRequest) (*notes.Note, error) { - args := m.Called(req) - return args.Get(0).(*notes.Note), args.Error(1) -} -func (m *NotesMock) Get(ctx context.Context, id uuid.UUID) (*notes.Note, error) { - args := m.Called(id) - return args.Get(0).(*notes.Note), args.Error(1) -} -func (m *NotesMock) Delete(ctx context.Context, req dto.NoteDeleteRequest, id uuid.UUID) error { - args := m.Called(id) - return args.Error(0) - -} - -type BoardsMock struct { - services.Boards - mock.Mock -} - -type SessionsMock struct { - mock.Mock -} - -func (m *SessionsMock) SessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *SessionsMock) ParticipantBanned(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *SessionsMock) Connect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(boardID, userID) - return args.Error(0) -} - -func (m *SessionsMock) Create(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSession), args.Error(1) -} - -// Add other missing methods here -func (m *SessionsMock) Get(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) Update(ctx context.Context, body dto.BoardSessionUpdateRequest) (*dto.BoardSession, error) { - args := m.Called(body) - return args.Get(0).(*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) UpdateAll(ctx context.Context, body dto.BoardSessionsUpdateRequest) ([]*dto.BoardSession, error) { - args := m.Called(body) - return args.Get(0).([]*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) List(ctx context.Context, boardID uuid.UUID, f filter.BoardSessionFilter) ([]*dto.BoardSession, error) { - args := m.Called(boardID, f) - return args.Get(0).([]*dto.BoardSession), args.Error(1) -} - -func (m *SessionsMock) Disconnect(ctx context.Context, boardID, userID uuid.UUID) error { - args := m.Called(boardID, userID) - return args.Error(0) -} - -func (m *SessionsMock) GetSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) CreateSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(boardID, userID) - return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) ListSessionRequest(ctx context.Context, boardID uuid.UUID, statusQuery string) ([]*dto.BoardSessionRequest, error) { - args := m.Called(boardID, statusQuery) - return args.Get(0).([]*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) UpdateSessionRequest(ctx context.Context, body dto.BoardSessionRequestUpdate) (*dto.BoardSessionRequest, error) { - args := m.Called(body) - return args.Get(0).(*dto.BoardSessionRequest), args.Error(1) -} - -func (m *SessionsMock) ModeratorSessionExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *SessionsMock) SessionRequestExists(ctx context.Context, boardID, userID uuid.UUID) (bool, error) { - args := m.Called(boardID, userID) - return args.Bool(0), args.Error(1) -} - -func (m *BoardsMock) Get(ctx context.Context, id uuid.UUID) (*dto.Board, error) { - args := m.Called(id) - return args.Get(0).(*dto.Board), args.Error(1) -} - type NotesTestSuite struct { suite.Suite } @@ -168,38 +56,37 @@ func (suite *NotesTestSuite) TestCreateNote() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(NotesMock) + noteMock := services.NewMockNotes(suite.T()) testText := "asdf" boardId, _ := uuid.NewRandom() userId, _ := uuid.NewRandom() colId, _ := uuid.NewRandom() - mock.On("Create", dto.NoteCreateRequest{ - Board: boardId, - User: userId, - Text: testText, - Column: colId, - }).Return(¬es.Note{ - Text: testText, - }, tt.err) - - s.notes = mock + s.notes = noteMock req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ "column": "%s", "text" : "%s" }`, colId.String(), testText))) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). AddToContext(identifiers.UserIdentifier, userId) + + noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ + Board: boardId, + User: userId, + Text: testText, + Column: colId, + }).Return(&dto.Note{ + Text: testText, + }, tt.err) + rr := httptest.NewRecorder() s.createNote(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + noteMock.AssertExpectations(suite.T()) }) } @@ -234,23 +121,23 @@ func (suite *NotesTestSuite) TestGetNote() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - mock := new(NotesMock) - s.notes = mock + noteMock := services.NewMockNotes(suite.T()) + s.notes = noteMock noteID, _ := uuid.NewRandom() - mock.On("Get", noteID).Return(¬es.Note{ - ID: noteID, - }, tt.err) - req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.NoteIdentifier, noteID) + noteMock.EXPECT().Get(req.req.Context(), noteID).Return(&dto.Note{ + ID: noteID, + }, tt.err) + rr := httptest.NewRecorder() s.getNote(rr, req.Request()) suite.Equal(tt.expectedCode, rr.Result().StatusCode) - mock.AssertExpectations(suite.T()) + noteMock.AssertExpectations(suite.T()) }) } } @@ -281,49 +168,49 @@ func (suite *NotesTestSuite) TestDeleteNote() { for _, tt := range tests { suite.Run(tt.name, func() { s := new(Server) - noteMock := new(NotesMock) + + noteMock := services.NewMockNotes(suite.T()) + boardMock := services.NewMockBoards(suite.T()) + sessionMock := services.NewMockBoardSessions(suite.T()) + s.notes = noteMock - boardMock := new(BoardsMock) s.boards = boardMock - sessionMock := new(SessionsMock) s.sessions = sessionMock boardID, _ := uuid.NewRandom() userID, _ := uuid.NewRandom() noteID, _ := uuid.NewRandom() + r := chi.NewRouter() s.initNoteResources(r) - boardMock.On("Get", boardID).Return(&dto.Board{ + + req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) + req.req = logger.InitTestLoggerRequest(req.Request()) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + req.AddToContext(identifiers.UserIdentifier, userID) + + boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ ID: boardID, IsLocked: tt.isLocked, }, nil) // Mock the SessionExists method - sessionMock.On("SessionExists", boardID, userID).Return(true, nil) + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) // Mock the ModeratorSessionExists method - sessionMock.On("ModeratorSessionExists", boardID, userID).Return(true, nil) + sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) // Mock the ParticipantBanned method - sessionMock.On("ParticipantBanned", boardID, userID).Return(false, nil) + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) if tt.isLocked { - noteMock.On("Delete", mock.Anything, mock.Anything).Return(nil) + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) } else { - boardMock.On("Get", boardID).Return(&dto.Board{ - ID: boardID, - IsLocked: tt.isLocked, - }, tt.err) - noteMock.On("Delete", mock.Anything).Return(tt.err) + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) } - req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) - req.req = logger.InitTestLoggerRequest(req.Request()) - rctx := chi.NewRouteContext() - rctx.URLParams.Add("id", boardID.String()) - req.AddToContext(chi.RouteCtxKey, rctx) - req.AddToContext(identifiers.UserIdentifier, userID) - rr := httptest.NewRecorder() r.ServeHTTP(rr, req.Request()) diff --git a/server/src/mocks/services/mock_Notes.go b/server/src/mocks/services/mock_Notes.go new file mode 100644 index 0000000000..66024de389 --- /dev/null +++ b/server/src/mocks/services/mock_Notes.go @@ -0,0 +1,382 @@ +// Code generated by mockery v2.51.0. DO NOT EDIT. + +package services + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + dto "scrumlr.io/server/common/dto" + + uuid "github.com/google/uuid" +) + +// MockNotes is an autogenerated mock type for the Notes type +type MockNotes struct { + mock.Mock +} + +type MockNotes_Expecter struct { + mock *mock.Mock +} + +func (_m *MockNotes) EXPECT() *MockNotes_Expecter { + return &MockNotes_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, body +func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteCreateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockNotes_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteCreateRequest +func (_e *MockNotes_Expecter) Create(ctx interface{}, body interface{}) *MockNotes_Create_Call { + return &MockNotes_Create_Call{Call: _e.mock.On("Create", ctx, body)} +} + +func (_c *MockNotes_Create_Call) Run(run func(ctx context.Context, body dto.NoteCreateRequest)) *MockNotes_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteCreateRequest)) + }) + return _c +} + +func (_c *MockNotes_Create_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)) *MockNotes_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, body, id +func (_m *MockNotes) Delete(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID) error { + ret := _m.Called(ctx, body, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error); ok { + r0 = rf(ctx, body, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockNotes_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockNotes_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteDeleteRequest +// - id uuid.UUID +func (_e *MockNotes_Expecter) Delete(ctx interface{}, body interface{}, id interface{}) *MockNotes_Delete_Call { + return &MockNotes_Delete_Call{Call: _e.mock.On("Delete", ctx, body, id)} +} + +func (_c *MockNotes_Delete_Call) Run(run func(ctx context.Context, body dto.NoteDeleteRequest, id uuid.UUID)) *MockNotes_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteDeleteRequest), args[2].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Delete_Call) Return(_a0 error) *MockNotes_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockNotes_Delete_Call) RunAndReturn(run func(context.Context, dto.NoteDeleteRequest, uuid.UUID) error) *MockNotes_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Get provides a mock function with given fields: ctx, id +func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockNotes_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) Get(ctx interface{}, id interface{}) *MockNotes_Get_Call { + return &MockNotes_Get_Call{Call: _e.mock.On("Get", ctx, id)} +} + +func (_c *MockNotes_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_Get_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Note, error)) *MockNotes_Get_Call { + _c.Call.Return(run) + return _c +} + +// Import provides a mock function with given fields: ctx, body +func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Import") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteImportRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Import_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Import' +type MockNotes_Import_Call struct { + *mock.Call +} + +// Import is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteImportRequest +func (_e *MockNotes_Expecter) Import(ctx interface{}, body interface{}) *MockNotes_Import_Call { + return &MockNotes_Import_Call{Call: _e.mock.On("Import", ctx, body)} +} + +func (_c *MockNotes_Import_Call) Run(run func(ctx context.Context, body dto.NoteImportRequest)) *MockNotes_Import_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteImportRequest)) + }) + return _c +} + +func (_c *MockNotes_Import_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Import_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*dto.Note, error)) *MockNotes_Import_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx, id +func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*dto.Note, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Note, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Note); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, uuid.UUID) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockNotes_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +// - id uuid.UUID +func (_e *MockNotes_Expecter) List(ctx interface{}, id interface{}) *MockNotes_List_Call { + return &MockNotes_List_Call{Call: _e.mock.On("List", ctx, id)} +} + +func (_c *MockNotes_List_Call) Run(run func(ctx context.Context, id uuid.UUID)) *MockNotes_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uuid.UUID)) + }) + return _c +} + +func (_c *MockNotes_List_Call) Return(_a0 []*dto.Note, _a1 error) *MockNotes_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Note, error)) *MockNotes_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, body +func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*dto.Note, error) { + ret := _m.Called(ctx, body) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *dto.Note + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)); ok { + return rf(ctx, body) + } + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *dto.Note); ok { + r0 = rf(ctx, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*dto.Note) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, dto.NoteUpdateRequest) error); ok { + r1 = rf(ctx, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockNotes_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockNotes_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - body dto.NoteUpdateRequest +func (_e *MockNotes_Expecter) Update(ctx interface{}, body interface{}) *MockNotes_Update_Call { + return &MockNotes_Update_Call{Call: _e.mock.On("Update", ctx, body)} +} + +func (_c *MockNotes_Update_Call) Run(run func(ctx context.Context, body dto.NoteUpdateRequest)) *MockNotes_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(dto.NoteUpdateRequest)) + }) + return _c +} + +func (_c *MockNotes_Update_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)) *MockNotes_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockNotes creates a new instance of MockNotes. 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 NewMockNotes(t interface { + mock.TestingT + Cleanup(func()) +}) *MockNotes { + mock := &MockNotes{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} From a8bbdf9c224f2c4d9cfab4d61f47a295aae0d8e5 Mon Sep 17 00:00:00 2001 From: wschoepke Date: Wed, 22 Jan 2025 12:13:15 +0100 Subject: [PATCH 22/27] 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 | 158 +++----- server/src/mocks/services/mock_Votings.go | 443 ++++++++++++++++++++++ 5 files changed, 537 insertions(+), 200 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 52114a1ce7..f950055bd2 100644 --- a/server/src/api/votings_test.go +++ b/server/src/api/votings_test.go @@ -1,61 +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/votes" + "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) (*votes.Voting, error) { - args := m.Called(boardID, id) - return args.Get(0).(*votes.Voting), args.Error(1) -} - -func (m *VotingMock) Update(ctx context.Context, body votes.VotingUpdateRequest) (*votes.Voting, error) { - args := m.Called(body) - return args.Get(0).(*votes.Voting), args.Error(1) -} - -func (m *VotingMock) Create(ctx context.Context, body votes.VotingCreateRequest) (*votes.Voting, error) { - args := m.Called(body) - return args.Get(0).(*votes.Voting), args.Error(1) -} - type VotingTestSuite struct { suite.Suite } @@ -66,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", votes.VotingCreateRequest{ - VoteLimit: 4, - AllowMultipleVotes: false, - ShowVotesOfOthers: false, - Board: boardId, - }).Return(&votes.Voting{ - AllowMultipleVotes: false, - ShowVotesOfOthers: false, - }, tt.err) - - s.votings = mock + s.votings = votingMock req := NewTestRequestBuilder("POST", "/", strings.NewReader(`{ "voteLimit": 4, @@ -112,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) }) } @@ -124,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", votes.VotingUpdateRequest{ - Board: boardId, - ID: votingId, - Status: types.VotingStatusClosed, - }).Return(&votes.Voting{ - Status: types.VotingStatusClosed, - }, tt.err) - - s.votings = mock + s.votings = votingMock req := NewTestRequestBuilder("PUT", "/", strings.NewReader(`{ "status": "CLOSED" @@ -165,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) }) } @@ -176,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(&votes.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 +} From 076c04063a2f811bddcd0a48dd0fe9bb0ab4294d Mon Sep 17 00:00:00 2001 From: Mateo Ivankovic Date: Thu, 13 Feb 2025 10:33:17 +0100 Subject: [PATCH 23/27] fix imports --- server/src/api/columns_test.go | 465 +++++++++--------- server/src/api/notes_test.go | 5 +- server/src/api/votings_test.go | 192 ++++---- .../src/mocks/services/mock_BoardSessions.go | 2 +- server/src/mocks/services/mock_Boards.go | 63 +-- server/src/mocks/services/mock_Notes.go | 74 +-- server/src/mocks/services/mock_Votings.go | 76 +-- 7 files changed, 443 insertions(+), 434 deletions(-) diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go index cf4ca46287..e395b5813d 100644 --- a/server/src/api/columns_test.go +++ b/server/src/api/columns_test.go @@ -1,261 +1,262 @@ package api import ( - "errors" - "fmt" - "github.com/google/uuid" - "github.com/stretchr/testify/suite" - "net/http" - "net/http/httptest" - "scrumlr.io/server/common" - "scrumlr.io/server/common/dto" - "scrumlr.io/server/database/types" - "scrumlr.io/server/identifiers" - "scrumlr.io/server/mocks/services" - "strings" - "testing" + "errors" + "fmt" + "github.com/google/uuid" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/columns" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/database/types" + "scrumlr.io/server/identifiers" + "scrumlr.io/server/mocks/services" + "strings" + "testing" ) type ColumnTestSuite struct { - suite.Suite + suite.Suite } func TestColumnTestSuite(t *testing.T) { - suite.Run(t, new(ColumnTestSuite)) + suite.Run(t, new(ColumnTestSuite)) } func (suite *ColumnTestSuite) TestCreateColumn() { - testParameterBundles := *TestParameterBundles{}. - Append("Successful created column", http.StatusCreated, nil, false, false, nil). - Append("Failed creating column", http.StatusInternalServerError, &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not create column", - }, false, false, nil) - - for _, tt := range testParameterBundles { - suite.Run(tt.name, func() { - s := new(Server) - boardMock := services.NewMockBoards(suite.T()) - name := "TestColumn" - color := types.Color("backlog-blue") - visible := true - index := 0 - boardID, _ := uuid.NewRandom() - userID, _ := uuid.NewRandom() - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( - `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, - ))).AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.UserIdentifier, userID) - rr := httptest.NewRecorder() - - boardMock.EXPECT().CreateColumn(req.req.Context(), dto.ColumnRequest{ - Name: name, - Color: color, - Visible: &visible, - Index: &index, - Board: boardID, - User: userID, - }).Return(&dto.Column{ - ID: uuid.UUID{}, - Name: name, - Color: color, - Visible: visible, - Index: index, - }, tt.err) - - s.boards = boardMock - - s.createColumn(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - boardMock.AssertExpectations(suite.T()) - }) - } + testParameterBundles := *TestParameterBundles{}. + Append("Successful created column", http.StatusCreated, nil, false, false, nil). + Append("Failed creating column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not create column", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + boardMock := services.NewMockBoards(suite.T()) + name := "TestColumn" + color := types.Color("backlog-blue") + visible := true + index := 0 + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf( + `{"name": "%s", "color": "%s", "visible": %t, "index": %d}`, name, color, visible, index, + ))).AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().CreateColumn(req.req.Context(), dto.ColumnRequest{ + Name: name, + Color: color, + Visible: &visible, + Index: &index, + Board: boardID, + User: userID, + }).Return(&columns.Column{ + ID: uuid.UUID{}, + Name: name, + Color: color, + Visible: visible, + Index: index, + }, tt.err) + + s.boards = boardMock + + s.createColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } } func (suite *ColumnTestSuite) TestDeleteColumn() { - testParameterBundles := *TestParameterBundles{}. - Append("Successful deleted column", http.StatusNoContent, nil, false, false, nil). - Append("Failed deleting column", http.StatusInternalServerError, &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not delete column", - }, false, false, nil) - - for _, tt := range testParameterBundles { - suite.Run(tt.name, func() { - s := new(Server) - boardMock := services.NewMockBoards(suite.T()) - boardID, _ := uuid.NewRandom() - columnID, _ := uuid.NewRandom() - userID, _ := uuid.NewRandom() - - req := NewTestRequestBuilder("DEL", "/", nil). - AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.UserIdentifier, userID). - AddToContext(identifiers.ColumnIdentifier, columnID) - rr := httptest.NewRecorder() - - boardMock.EXPECT().DeleteColumn(req.req.Context(), boardID, columnID, userID).Return(tt.err) - - s.boards = boardMock - s.deleteColumn(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - boardMock.AssertExpectations(suite.T()) - }) - } + testParameterBundles := *TestParameterBundles{}. + Append("Successful deleted column", http.StatusNoContent, nil, false, false, nil). + Append("Failed deleting column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not delete column", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + boardMock := services.NewMockBoards(suite.T()) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + + req := NewTestRequestBuilder("DEL", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.UserIdentifier, userID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().DeleteColumn(req.req.Context(), boardID, columnID, userID).Return(tt.err) + + s.boards = boardMock + s.deleteColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } } func (suite *ColumnTestSuite) TestUpdateColumn() { - testParameterBundles := *TestParameterBundles{}. - Append("Successful updated column", http.StatusOK, nil, false, false, nil). - Append("Failed updating column", http.StatusInternalServerError, &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not update column", - }, false, false, nil) - - for _, tt := range testParameterBundles { - suite.Run(tt.name, func() { - s := new(Server) - boardMock := services.NewMockBoards(suite.T()) - boardID, _ := uuid.NewRandom() - columnID, _ := uuid.NewRandom() - - colName := "TestColumn" - color := types.Color("online-orange") - visible := false - index := 0 - - req := NewTestRequestBuilder("PUT", "/", strings.NewReader( - fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). - AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.ColumnIdentifier, columnID) - rr := httptest.NewRecorder() - - boardMock.EXPECT().UpdateColumn(req.req.Context(), dto.ColumnUpdateRequest{ - Name: colName, - Color: color, - Visible: visible, - Index: index, - ID: columnID, - Board: boardID, - }).Return(&dto.Column{ - ID: columnID, - Name: colName, - Color: color, - Visible: visible, - Index: index, - }, tt.err) - - s.boards = boardMock - - s.updateColumn(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - boardMock.AssertExpectations(suite.T()) - }) - } + testParameterBundles := *TestParameterBundles{}. + Append("Successful updated column", http.StatusOK, nil, false, false, nil). + Append("Failed updating column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not update column", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + boardMock := services.NewMockBoards(suite.T()) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "TestColumn" + color := types.Color("online-orange") + visible := false + index := 0 + + req := NewTestRequestBuilder("PUT", "/", strings.NewReader( + fmt.Sprintf(`{"name": "%s", "color": "%s", "visible": %v, "index": %d }`, colName, color, visible, index))). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().UpdateColumn(req.req.Context(), dto.ColumnUpdateRequest{ + Name: colName, + Color: color, + Visible: visible, + Index: index, + ID: columnID, + Board: boardID, + }).Return(&columns.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + }, tt.err) + + s.boards = boardMock + + s.updateColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } } func (suite *ColumnTestSuite) TestGetColumn() { - testParameterBundles := *TestParameterBundles{}. - Append("Successful get column", http.StatusOK, nil, false, false, nil). - Append("Failed getting column", http.StatusInternalServerError, &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not get column", - }, false, false, nil) - - for _, tt := range testParameterBundles { - suite.Run(tt.name, func() { - s := new(Server) - boardMock := services.NewMockBoards(suite.T()) - boardID, _ := uuid.NewRandom() - columnID, _ := uuid.NewRandom() - - colName := "Updated Column Name" - color := types.Color("online-orange") - visible := false - index := 0 - - column := &dto.Column{ - ID: columnID, - Name: colName, - Color: color, - Visible: visible, - Index: index, - } - - req := NewTestRequestBuilder("GET", "/", nil). - AddToContext(identifiers.BoardIdentifier, boardID). - AddToContext(identifiers.ColumnIdentifier, columnID) - rr := httptest.NewRecorder() - - boardMock.EXPECT().GetColumn(req.req.Context(), boardID, columnID).Return(column, tt.err) - - s.boards = boardMock - - s.getColumn(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - boardMock.AssertExpectations(suite.T()) - }) - } + testParameterBundles := *TestParameterBundles{}. + Append("Successful get column", http.StatusOK, nil, false, false, nil). + Append("Failed getting column", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get column", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + boardMock := services.NewMockBoards(suite.T()) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "Updated Column Name" + color := types.Color("online-orange") + visible := false + index := 0 + + column := &columns.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + } + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID). + AddToContext(identifiers.ColumnIdentifier, columnID) + rr := httptest.NewRecorder() + + boardMock.EXPECT().GetColumn(req.req.Context(), boardID, columnID).Return(column, tt.err) + + s.boards = boardMock + + s.getColumn(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } } func (suite *ColumnTestSuite) TestGetColumns() { - testParameterBundles := *TestParameterBundles{}. - Append("Successful get columns", http.StatusOK, nil, false, false, nil). - Append("Failed getting columns", http.StatusInternalServerError, &common.APIError{ - Err: errors.New(""), - StatusCode: http.StatusInternalServerError, - StatusText: "no", - ErrorText: "Could not get columns", - }, false, false, nil) - - for _, tt := range testParameterBundles { - suite.Run(tt.name, func() { - s := new(Server) - boardMock := services.NewMockBoards(suite.T()) - boardID, _ := uuid.NewRandom() - columnID, _ := uuid.NewRandom() - - colName := "TestColumn" - color := types.Color("online-orange") - visible := false - index := 0 - - column := &dto.Column{ - ID: columnID, - Name: colName, - Color: color, - Visible: visible, - Index: index, - } - - req := NewTestRequestBuilder("GET", "/", nil). - AddToContext(identifiers.BoardIdentifier, boardID) - rr := httptest.NewRecorder() - boardMock.EXPECT().ListColumns(req.req.Context(), boardID).Return([]*dto.Column{column}, tt.err) - - s.boards = boardMock - - s.getColumns(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - boardMock.AssertExpectations(suite.T()) - }) - } + testParameterBundles := *TestParameterBundles{}. + Append("Successful get columns", http.StatusOK, nil, false, false, nil). + Append("Failed getting columns", http.StatusInternalServerError, &common.APIError{ + Err: errors.New(""), + StatusCode: http.StatusInternalServerError, + StatusText: "no", + ErrorText: "Could not get columns", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + boardMock := services.NewMockBoards(suite.T()) + boardID, _ := uuid.NewRandom() + columnID, _ := uuid.NewRandom() + + colName := "TestColumn" + color := types.Color("online-orange") + visible := false + index := 0 + + column := &columns.Column{ + ID: columnID, + Name: colName, + Color: color, + Visible: visible, + Index: index, + } + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardID) + rr := httptest.NewRecorder() + boardMock.EXPECT().ListColumns(req.req.Context(), boardID).Return([]*columns.Column{column}, tt.err) + + s.boards = boardMock + + s.getColumns(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } } diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index eead457755..8f07f870d8 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -14,6 +14,7 @@ import ( "scrumlr.io/server/identifiers" "scrumlr.io/server/logger" "scrumlr.io/server/mocks/services" + "scrumlr.io/server/notes" "strings" "testing" ) @@ -63,7 +64,7 @@ func (suite *NotesTestSuite) TestCreateNote() { User: userId, Text: testText, Column: colId, - }).Return(&dto.Note{ + }).Return(¬es.Note{ Text: testText, }, tt.err) @@ -99,7 +100,7 @@ func (suite *NotesTestSuite) TestGetNote() { req := NewTestRequestBuilder("GET", "/", nil). AddToContext(identifiers.NoteIdentifier, noteID) - noteMock.EXPECT().Get(req.req.Context(), noteID).Return(&dto.Note{ + noteMock.EXPECT().Get(req.req.Context(), noteID).Return(¬es.Note{ ID: noteID, }, tt.err) diff --git a/server/src/api/votings_test.go b/server/src/api/votings_test.go index f950055bd2..5a054c59ff 100644 --- a/server/src/api/votings_test.go +++ b/server/src/api/votings_test.go @@ -1,131 +1,131 @@ package api import ( - "errors" - "net/http" - "net/http/httptest" - "scrumlr.io/server/common" - "scrumlr.io/server/common/dto" - "scrumlr.io/server/identifiers" - "scrumlr.io/server/logger" - "scrumlr.io/server/mocks/services" - "strings" - "testing" - - "github.com/google/uuid" - - "github.com/stretchr/testify/suite" - "scrumlr.io/server/database/types" + "errors" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/identifiers" + "scrumlr.io/server/logger" + "scrumlr.io/server/mocks/services" + "scrumlr.io/server/votes" + "strings" + "testing" + + "github.com/google/uuid" + + "github.com/stretchr/testify/suite" + "scrumlr.io/server/database/types" ) type VotingTestSuite struct { - suite.Suite + suite.Suite } func TestVotingTestSuite(t *testing.T) { - suite.Run(t, new(VotingTestSuite)) + suite.Run(t, new(VotingTestSuite)) } func (suite *VotingTestSuite) TestCreateVoting() { - 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) + 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) - votingMock := services.NewMockVotings(suite.T()) + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + votingMock := services.NewMockVotings(suite.T()) - boardId, _ := uuid.NewRandom() - s.votings = votingMock + boardId, _ := uuid.NewRandom() + s.votings = votingMock - req := NewTestRequestBuilder("POST", "/", strings.NewReader(`{ + req := NewTestRequestBuilder("POST", "/", strings.NewReader(`{ "voteLimit": 4, "allowMultipleVotes": false, "showVotesOfOthers": false }`)) - 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) - votingMock.AssertExpectations(suite.T()) - votingMock.AssertNumberOfCalls(suite.T(), "Create", 1) - }) - } + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId) + + votingMock.EXPECT().Create(req.req.Context(), votes.VotingCreateRequest{ + VoteLimit: 4, + AllowMultipleVotes: false, + ShowVotesOfOthers: false, + Board: boardId, + }).Return(&votes.Voting{ + AllowMultipleVotes: false, + ShowVotesOfOthers: false, + }, tt.err) + + rr := httptest.NewRecorder() + s.createVoting(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + votingMock.AssertExpectations(suite.T()) + votingMock.AssertNumberOfCalls(suite.T(), "Create", 1) + }) + } } func (suite *VotingTestSuite) TestUpdateVoting() { - testParameterBundles := *TestParameterBundles{}. - Append("all ok", http.StatusOK, nil, false, false, nil). - Append("unexpected error", http.StatusInternalServerError, errors.New("oops"), false, false, nil) + 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) - votingMock := services.NewMockVotings(suite.T()) - boardId, _ := uuid.NewRandom() - votingId, _ := uuid.NewRandom() + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + votingMock := services.NewMockVotings(suite.T()) + boardId, _ := uuid.NewRandom() + votingId, _ := uuid.NewRandom() - s.votings = votingMock + s.votings = votingMock - req := NewTestRequestBuilder("PUT", "/", strings.NewReader(`{ + req := NewTestRequestBuilder("PUT", "/", strings.NewReader(`{ "status": "CLOSED" }`)) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). - 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) - votingMock.AssertExpectations(suite.T()) - votingMock.AssertNumberOfCalls(suite.T(), "Update", 1) - }) - } + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.VotingIdentifier, votingId) + rr := httptest.NewRecorder() + + votingMock.EXPECT().Update(req.req.Context(), votes.VotingUpdateRequest{ + Board: boardId, + ID: votingId, + Status: types.VotingStatusClosed, + }).Return(&votes.Voting{ + Status: types.VotingStatusClosed, + }, tt.err) + + s.updateVoting(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + votingMock.AssertExpectations(suite.T()) + votingMock.AssertNumberOfCalls(suite.T(), "Update", 1) + }) + } } func (suite *VotingTestSuite) TestGetVoting() { - s := new(Server) - votingMock := services.NewMockVotings(suite.T()) - s.votings = votingMock - boardId, _ := uuid.NewRandom() - votingId, _ := uuid.NewRandom() - - req := NewTestRequestBuilder("GET", "/", nil). - AddToContext(identifiers.BoardIdentifier, boardId). - AddToContext(identifiers.VotingIdentifier, votingId) - rr := httptest.NewRecorder() - - 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()) + s := new(Server) + votingMock := services.NewMockVotings(suite.T()) + s.votings = votingMock + boardId, _ := uuid.NewRandom() + votingId, _ := uuid.NewRandom() + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.VotingIdentifier, votingId) + rr := httptest.NewRecorder() + + votingMock.EXPECT().Get(req.req.Context(), boardId, votingId).Return(&votes.Voting{ + ID: votingId, + Status: types.VotingStatusClosed, + }, nil) + + s.getVoting(rr, req.Request()) + votingMock.AssertExpectations(suite.T()) } diff --git a/server/src/mocks/services/mock_BoardSessions.go b/server/src/mocks/services/mock_BoardSessions.go index bc2cac6dfd..c30f5cf67c 100644 --- a/server/src/mocks/services/mock_BoardSessions.go +++ b/server/src/mocks/services/mock_BoardSessions.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. +// Code generated by mockery v2.52.2. DO NOT EDIT. package services diff --git a/server/src/mocks/services/mock_Boards.go b/server/src/mocks/services/mock_Boards.go index 34ade264b0..2ac5560628 100644 --- a/server/src/mocks/services/mock_Boards.go +++ b/server/src/mocks/services/mock_Boards.go @@ -1,13 +1,16 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. +// Code generated by mockery v2.52.2. DO NOT EDIT. package services import ( context "context" - mock "github.com/stretchr/testify/mock" + columns "scrumlr.io/server/columns" + dto "scrumlr.io/server/common/dto" + mock "github.com/stretchr/testify/mock" + uuid "github.com/google/uuid" ) @@ -144,23 +147,23 @@ func (_c *MockBoards_Create_Call) RunAndReturn(run func(context.Context, dto.Cre } // CreateColumn provides a mock function with given fields: ctx, body -func (_m *MockBoards) CreateColumn(ctx context.Context, body dto.ColumnRequest) (*dto.Column, error) { +func (_m *MockBoards) CreateColumn(ctx context.Context, body dto.ColumnRequest) (*columns.Column, error) { ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for CreateColumn") } - var r0 *dto.Column + var r0 *columns.Column var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) (*dto.Column, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) (*columns.Column, error)); ok { return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) *dto.Column); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnRequest) *columns.Column); ok { r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Column) + r0 = ret.Get(0).(*columns.Column) } } @@ -192,12 +195,12 @@ func (_c *MockBoards_CreateColumn_Call) Run(run func(ctx context.Context, body d return _c } -func (_c *MockBoards_CreateColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_CreateColumn_Call { +func (_c *MockBoards_CreateColumn_Call) Return(_a0 *columns.Column, _a1 error) *MockBoards_CreateColumn_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockBoards_CreateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnRequest) (*dto.Column, error)) *MockBoards_CreateColumn_Call { +func (_c *MockBoards_CreateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnRequest) (*columns.Column, error)) *MockBoards_CreateColumn_Call { _c.Call.Return(run) return _c } @@ -535,23 +538,23 @@ func (_c *MockBoards_GetBoards_Call) RunAndReturn(run func(context.Context, uuid } // GetColumn provides a mock function with given fields: ctx, boardID, columnID -func (_m *MockBoards) GetColumn(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*dto.Column, error) { +func (_m *MockBoards) GetColumn(ctx context.Context, boardID uuid.UUID, columnID uuid.UUID) (*columns.Column, error) { ret := _m.Called(ctx, boardID, columnID) if len(ret) == 0 { panic("no return value specified for GetColumn") } - var r0 *dto.Column + var r0 *columns.Column var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.Column, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*columns.Column, error)); ok { return rf(ctx, boardID, columnID) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.Column); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *columns.Column); ok { r0 = rf(ctx, boardID, columnID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Column) + r0 = ret.Get(0).(*columns.Column) } } @@ -584,12 +587,12 @@ func (_c *MockBoards_GetColumn_Call) Run(run func(ctx context.Context, boardID u return _c } -func (_c *MockBoards_GetColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_GetColumn_Call { +func (_c *MockBoards_GetColumn_Call) Return(_a0 *columns.Column, _a1 error) *MockBoards_GetColumn_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockBoards_GetColumn_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*dto.Column, error)) *MockBoards_GetColumn_Call { +func (_c *MockBoards_GetColumn_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*columns.Column, error)) *MockBoards_GetColumn_Call { _c.Call.Return(run) return _c } @@ -654,23 +657,23 @@ func (_c *MockBoards_IncrementTimer_Call) RunAndReturn(run func(context.Context, } // ListColumns provides a mock function with given fields: ctx, boardID -func (_m *MockBoards) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*dto.Column, error) { +func (_m *MockBoards) ListColumns(ctx context.Context, boardID uuid.UUID) ([]*columns.Column, error) { ret := _m.Called(ctx, boardID) if len(ret) == 0 { panic("no return value specified for ListColumns") } - var r0 []*dto.Column + var r0 []*columns.Column var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Column, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*columns.Column, error)); ok { return rf(ctx, boardID) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Column); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*columns.Column); ok { r0 = rf(ctx, boardID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.Column) + r0 = ret.Get(0).([]*columns.Column) } } @@ -702,12 +705,12 @@ func (_c *MockBoards_ListColumns_Call) Run(run func(ctx context.Context, boardID return _c } -func (_c *MockBoards_ListColumns_Call) Return(_a0 []*dto.Column, _a1 error) *MockBoards_ListColumns_Call { +func (_c *MockBoards_ListColumns_Call) Return(_a0 []*columns.Column, _a1 error) *MockBoards_ListColumns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockBoards_ListColumns_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Column, error)) *MockBoards_ListColumns_Call { +func (_c *MockBoards_ListColumns_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*columns.Column, error)) *MockBoards_ListColumns_Call { _c.Call.Return(run) return _c } @@ -832,23 +835,23 @@ func (_c *MockBoards_Update_Call) RunAndReturn(run func(context.Context, dto.Boa } // UpdateColumn provides a mock function with given fields: ctx, body -func (_m *MockBoards) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*dto.Column, error) { +func (_m *MockBoards) UpdateColumn(ctx context.Context, body dto.ColumnUpdateRequest) (*columns.Column, error) { ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for UpdateColumn") } - var r0 *dto.Column + var r0 *columns.Column var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) (*dto.Column, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) (*columns.Column, error)); ok { return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) *dto.Column); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.ColumnUpdateRequest) *columns.Column); ok { r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Column) + r0 = ret.Get(0).(*columns.Column) } } @@ -880,12 +883,12 @@ func (_c *MockBoards_UpdateColumn_Call) Run(run func(ctx context.Context, body d return _c } -func (_c *MockBoards_UpdateColumn_Call) Return(_a0 *dto.Column, _a1 error) *MockBoards_UpdateColumn_Call { +func (_c *MockBoards_UpdateColumn_Call) Return(_a0 *columns.Column, _a1 error) *MockBoards_UpdateColumn_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockBoards_UpdateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnUpdateRequest) (*dto.Column, error)) *MockBoards_UpdateColumn_Call { +func (_c *MockBoards_UpdateColumn_Call) RunAndReturn(run func(context.Context, dto.ColumnUpdateRequest) (*columns.Column, error)) *MockBoards_UpdateColumn_Call { _c.Call.Return(run) return _c } diff --git a/server/src/mocks/services/mock_Notes.go b/server/src/mocks/services/mock_Notes.go index 66024de389..46820dc1a7 100644 --- a/server/src/mocks/services/mock_Notes.go +++ b/server/src/mocks/services/mock_Notes.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. +// Code generated by mockery v2.52.2. DO NOT EDIT. package services @@ -8,6 +8,8 @@ import ( mock "github.com/stretchr/testify/mock" dto "scrumlr.io/server/common/dto" + notes "scrumlr.io/server/notes" + uuid "github.com/google/uuid" ) @@ -25,23 +27,23 @@ func (_m *MockNotes) EXPECT() *MockNotes_Expecter { } // Create provides a mock function with given fields: ctx, body -func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*dto.Note, error) { +func (_m *MockNotes) Create(ctx context.Context, body dto.NoteCreateRequest) (*notes.Note, error) { ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for Create") } - var r0 *dto.Note + var r0 *notes.Note var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) (*notes.Note, error)); ok { return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *dto.Note); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteCreateRequest) *notes.Note); ok { r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) + r0 = ret.Get(0).(*notes.Note) } } @@ -73,12 +75,12 @@ func (_c *MockNotes_Create_Call) Run(run func(ctx context.Context, body dto.Note return _c } -func (_c *MockNotes_Create_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Create_Call { +func (_c *MockNotes_Create_Call) Return(_a0 *notes.Note, _a1 error) *MockNotes_Create_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*dto.Note, error)) *MockNotes_Create_Call { +func (_c *MockNotes_Create_Call) RunAndReturn(run func(context.Context, dto.NoteCreateRequest) (*notes.Note, error)) *MockNotes_Create_Call { _c.Call.Return(run) return _c } @@ -132,23 +134,23 @@ func (_c *MockNotes_Delete_Call) RunAndReturn(run func(context.Context, dto.Note } // Get provides a mock function with given fields: ctx, id -func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*dto.Note, error) { +func (_m *MockNotes) Get(ctx context.Context, id uuid.UUID) (*notes.Note, error) { ret := _m.Called(ctx, id) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *dto.Note + var r0 *notes.Note var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*dto.Note, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) (*notes.Note, error)); ok { return rf(ctx, id) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *dto.Note); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) *notes.Note); ok { r0 = rf(ctx, id) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) + r0 = ret.Get(0).(*notes.Note) } } @@ -180,34 +182,34 @@ func (_c *MockNotes_Get_Call) Run(run func(ctx context.Context, id uuid.UUID)) * return _c } -func (_c *MockNotes_Get_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Get_Call { +func (_c *MockNotes_Get_Call) Return(_a0 *notes.Note, _a1 error) *MockNotes_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*dto.Note, error)) *MockNotes_Get_Call { +func (_c *MockNotes_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID) (*notes.Note, error)) *MockNotes_Get_Call { _c.Call.Return(run) return _c } // Import provides a mock function with given fields: ctx, body -func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*dto.Note, error) { +func (_m *MockNotes) Import(ctx context.Context, body dto.NoteImportRequest) (*notes.Note, error) { ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for Import") } - var r0 *dto.Note + var r0 *notes.Note var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*dto.Note, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) (*notes.Note, error)); ok { return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *dto.Note); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteImportRequest) *notes.Note); ok { r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) + r0 = ret.Get(0).(*notes.Note) } } @@ -239,34 +241,34 @@ func (_c *MockNotes_Import_Call) Run(run func(ctx context.Context, body dto.Note return _c } -func (_c *MockNotes_Import_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Import_Call { +func (_c *MockNotes_Import_Call) Return(_a0 *notes.Note, _a1 error) *MockNotes_Import_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*dto.Note, error)) *MockNotes_Import_Call { +func (_c *MockNotes_Import_Call) RunAndReturn(run func(context.Context, dto.NoteImportRequest) (*notes.Note, error)) *MockNotes_Import_Call { _c.Call.Return(run) return _c } // List provides a mock function with given fields: ctx, id -func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*dto.Note, error) { +func (_m *MockNotes) List(ctx context.Context, id uuid.UUID) ([]*notes.Note, error) { ret := _m.Called(ctx, id) if len(ret) == 0 { panic("no return value specified for List") } - var r0 []*dto.Note + var r0 []*notes.Note var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Note, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*notes.Note, error)); ok { return rf(ctx, id) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Note); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*notes.Note); ok { r0 = rf(ctx, id) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.Note) + r0 = ret.Get(0).([]*notes.Note) } } @@ -298,34 +300,34 @@ func (_c *MockNotes_List_Call) Run(run func(ctx context.Context, id uuid.UUID)) return _c } -func (_c *MockNotes_List_Call) Return(_a0 []*dto.Note, _a1 error) *MockNotes_List_Call { +func (_c *MockNotes_List_Call) Return(_a0 []*notes.Note, _a1 error) *MockNotes_List_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*dto.Note, error)) *MockNotes_List_Call { +func (_c *MockNotes_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*notes.Note, error)) *MockNotes_List_Call { _c.Call.Return(run) return _c } // Update provides a mock function with given fields: ctx, body -func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*dto.Note, error) { +func (_m *MockNotes) Update(ctx context.Context, body dto.NoteUpdateRequest) (*notes.Note, error) { ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for Update") } - var r0 *dto.Note + var r0 *notes.Note var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) (*notes.Note, error)); ok { return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *dto.Note); ok { + if rf, ok := ret.Get(0).(func(context.Context, dto.NoteUpdateRequest) *notes.Note); ok { r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Note) + r0 = ret.Get(0).(*notes.Note) } } @@ -357,12 +359,12 @@ func (_c *MockNotes_Update_Call) Run(run func(ctx context.Context, body dto.Note return _c } -func (_c *MockNotes_Update_Call) Return(_a0 *dto.Note, _a1 error) *MockNotes_Update_Call { +func (_c *MockNotes_Update_Call) Return(_a0 *notes.Note, _a1 error) *MockNotes_Update_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*dto.Note, error)) *MockNotes_Update_Call { +func (_c *MockNotes_Update_Call) RunAndReturn(run func(context.Context, dto.NoteUpdateRequest) (*notes.Note, error)) *MockNotes_Update_Call { _c.Call.Return(run) return _c } diff --git a/server/src/mocks/services/mock_Votings.go b/server/src/mocks/services/mock_Votings.go index 0d0a5d69be..7a5351ce39 100644 --- a/server/src/mocks/services/mock_Votings.go +++ b/server/src/mocks/services/mock_Votings.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.51.0. DO NOT EDIT. +// Code generated by mockery v2.52.2. DO NOT EDIT. package services @@ -11,6 +11,8 @@ import ( mock "github.com/stretchr/testify/mock" uuid "github.com/google/uuid" + + votes "scrumlr.io/server/votes" ) // MockVotings is an autogenerated mock type for the Votings type @@ -86,27 +88,27 @@ func (_c *MockVotings_AddVote_Call) RunAndReturn(run func(context.Context, dto.V } // Create provides a mock function with given fields: ctx, body -func (_m *MockVotings) Create(ctx context.Context, body dto.VotingCreateRequest) (*dto.Voting, error) { +func (_m *MockVotings) Create(ctx context.Context, body votes.VotingCreateRequest) (*votes.Voting, error) { ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for Create") } - var r0 *dto.Voting + var r0 *votes.Voting var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.VotingCreateRequest) (*dto.Voting, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, votes.VotingCreateRequest) (*votes.Voting, error)); ok { return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(context.Context, dto.VotingCreateRequest) *dto.Voting); ok { + if rf, ok := ret.Get(0).(func(context.Context, votes.VotingCreateRequest) *votes.Voting); ok { r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Voting) + r0 = ret.Get(0).(*votes.Voting) } } - if rf, ok := ret.Get(1).(func(context.Context, dto.VotingCreateRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, votes.VotingCreateRequest) error); ok { r1 = rf(ctx, body) } else { r1 = ret.Error(1) @@ -122,46 +124,46 @@ type MockVotings_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - body dto.VotingCreateRequest +// - body votes.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 { +func (_c *MockVotings_Create_Call) Run(run func(ctx context.Context, body votes.VotingCreateRequest)) *MockVotings_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.VotingCreateRequest)) + run(args[0].(context.Context), args[1].(votes.VotingCreateRequest)) }) return _c } -func (_c *MockVotings_Create_Call) Return(_a0 *dto.Voting, _a1 error) *MockVotings_Create_Call { +func (_c *MockVotings_Create_Call) Return(_a0 *votes.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 { +func (_c *MockVotings_Create_Call) RunAndReturn(run func(context.Context, votes.VotingCreateRequest) (*votes.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) { +func (_m *MockVotings) Get(ctx context.Context, board uuid.UUID, id uuid.UUID) (*votes.Voting, error) { ret := _m.Called(ctx, board, id) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *dto.Voting + var r0 *votes.Voting var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*dto.Voting, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) (*votes.Voting, error)); ok { return rf(ctx, board, id) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *dto.Voting); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID, uuid.UUID) *votes.Voting); ok { r0 = rf(ctx, board, id) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Voting) + r0 = ret.Get(0).(*votes.Voting) } } @@ -194,12 +196,12 @@ func (_c *MockVotings_Get_Call) Run(run func(ctx context.Context, board uuid.UUI return _c } -func (_c *MockVotings_Get_Call) Return(_a0 *dto.Voting, _a1 error) *MockVotings_Get_Call { +func (_c *MockVotings_Get_Call) Return(_a0 *votes.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 { +func (_c *MockVotings_Get_Call) RunAndReturn(run func(context.Context, uuid.UUID, uuid.UUID) (*votes.Voting, error)) *MockVotings_Get_Call { _c.Call.Return(run) return _c } @@ -264,23 +266,23 @@ func (_c *MockVotings_GetVotes_Call) RunAndReturn(run func(context.Context, filt } // List provides a mock function with given fields: ctx, board -func (_m *MockVotings) List(ctx context.Context, board uuid.UUID) ([]*dto.Voting, error) { +func (_m *MockVotings) List(ctx context.Context, board uuid.UUID) ([]*votes.Voting, error) { ret := _m.Called(ctx, board) if len(ret) == 0 { panic("no return value specified for List") } - var r0 []*dto.Voting + var r0 []*votes.Voting var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*dto.Voting, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) ([]*votes.Voting, error)); ok { return rf(ctx, board) } - if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*dto.Voting); ok { + if rf, ok := ret.Get(0).(func(context.Context, uuid.UUID) []*votes.Voting); ok { r0 = rf(ctx, board) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*dto.Voting) + r0 = ret.Get(0).([]*votes.Voting) } } @@ -312,12 +314,12 @@ func (_c *MockVotings_List_Call) Run(run func(ctx context.Context, board uuid.UU return _c } -func (_c *MockVotings_List_Call) Return(_a0 []*dto.Voting, _a1 error) *MockVotings_List_Call { +func (_c *MockVotings_List_Call) Return(_a0 []*votes.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 { +func (_c *MockVotings_List_Call) RunAndReturn(run func(context.Context, uuid.UUID) ([]*votes.Voting, error)) *MockVotings_List_Call { _c.Call.Return(run) return _c } @@ -370,27 +372,27 @@ func (_c *MockVotings_RemoveVote_Call) RunAndReturn(run func(context.Context, dt } // Update provides a mock function with given fields: ctx, body -func (_m *MockVotings) Update(ctx context.Context, body dto.VotingUpdateRequest) (*dto.Voting, error) { +func (_m *MockVotings) Update(ctx context.Context, body votes.VotingUpdateRequest) (*votes.Voting, error) { ret := _m.Called(ctx, body) if len(ret) == 0 { panic("no return value specified for Update") } - var r0 *dto.Voting + var r0 *votes.Voting var r1 error - if rf, ok := ret.Get(0).(func(context.Context, dto.VotingUpdateRequest) (*dto.Voting, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, votes.VotingUpdateRequest) (*votes.Voting, error)); ok { return rf(ctx, body) } - if rf, ok := ret.Get(0).(func(context.Context, dto.VotingUpdateRequest) *dto.Voting); ok { + if rf, ok := ret.Get(0).(func(context.Context, votes.VotingUpdateRequest) *votes.Voting); ok { r0 = rf(ctx, body) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*dto.Voting) + r0 = ret.Get(0).(*votes.Voting) } } - if rf, ok := ret.Get(1).(func(context.Context, dto.VotingUpdateRequest) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, votes.VotingUpdateRequest) error); ok { r1 = rf(ctx, body) } else { r1 = ret.Error(1) @@ -406,24 +408,24 @@ type MockVotings_Update_Call struct { // Update is a helper method to define mock.On call // - ctx context.Context -// - body dto.VotingUpdateRequest +// - body votes.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 { +func (_c *MockVotings_Update_Call) Run(run func(ctx context.Context, body votes.VotingUpdateRequest)) *MockVotings_Update_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(dto.VotingUpdateRequest)) + run(args[0].(context.Context), args[1].(votes.VotingUpdateRequest)) }) return _c } -func (_c *MockVotings_Update_Call) Return(_a0 *dto.Voting, _a1 error) *MockVotings_Update_Call { +func (_c *MockVotings_Update_Call) Return(_a0 *votes.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 { +func (_c *MockVotings_Update_Call) RunAndReturn(run func(context.Context, votes.VotingUpdateRequest) (*votes.Voting, error)) *MockVotings_Update_Call { _c.Call.Return(run) return _c } From 7af8f3dafe73af8599b067cb22afac25f4fdfe6a Mon Sep 17 00:00:00 2001 From: Mateo Ivankovic Date: Thu, 13 Feb 2025 12:02:43 +0100 Subject: [PATCH 24/27] add edit note test --- server/src/api/notes_test.go | 399 ++++++++++++++++++++--------------- 1 file changed, 228 insertions(+), 171 deletions(-) diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index 8f07f870d8..6afe88f49c 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -1,195 +1,252 @@ package api import ( - "errors" - "fmt" - "github.com/go-chi/chi/v5" - "github.com/google/uuid" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/suite" - "net/http" - "net/http/httptest" - "scrumlr.io/server/common" - "scrumlr.io/server/common/dto" - "scrumlr.io/server/identifiers" - "scrumlr.io/server/logger" - "scrumlr.io/server/mocks/services" - "scrumlr.io/server/notes" - "strings" - "testing" + "bytes" + "encoding/json" + "errors" + "fmt" + "github.com/go-chi/chi/v5" + "github.com/google/uuid" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/identifiers" + "scrumlr.io/server/logger" + "scrumlr.io/server/mocks/services" + "scrumlr.io/server/notes" + "strings" + "testing" ) type NotesTestSuite struct { - suite.Suite + suite.Suite } func TestNotesTestSuite(t *testing.T) { - suite.Run(t, new(NotesTestSuite)) + suite.Run(t, new(NotesTestSuite)) } func (suite *NotesTestSuite) TestCreateNote() { - 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()) - testText := "asdf" - - boardId, _ := uuid.NewRandom() - userId, _ := uuid.NewRandom() - colId, _ := uuid.NewRandom() - - s.notes = noteMock - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ + 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()) + testText := "asdf" + + boardId, _ := uuid.NewRandom() + userId, _ := uuid.NewRandom() + colId, _ := uuid.NewRandom() + + s.notes = noteMock + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ "column": "%s", "text" : "%s" }`, colId.String(), testText))) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). - AddToContext(identifiers.UserIdentifier, userId) - - noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ - Board: boardId, - User: userId, - Text: testText, - Column: colId, - }).Return(¬es.Note{ - Text: testText, - }, tt.err) - - rr := httptest.NewRecorder() - - s.createNote(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - }) - } + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.UserIdentifier, userId) + + noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ + Board: boardId, + User: userId, + Text: testText, + Column: colId, + }).Return(¬es.Note{ + Text: testText, + }, tt.err) + + rr := httptest.NewRecorder() + + s.createNote(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestGetNote() { - 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()) - s.notes = noteMock - - noteID, _ := uuid.NewRandom() - - req := NewTestRequestBuilder("GET", "/", nil). - AddToContext(identifiers.NoteIdentifier, noteID) - - noteMock.EXPECT().Get(req.req.Context(), noteID).Return(¬es.Note{ - ID: noteID, - }, tt.err) - - rr := httptest.NewRecorder() - - s.getNote(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - }) - } + 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()) + s.notes = noteMock + + noteID, _ := uuid.NewRandom() + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.NoteIdentifier, noteID) + + noteMock.EXPECT().Get(req.req.Context(), noteID).Return(¬es.Note{ + ID: noteID, + }, tt.err) + + rr := httptest.NewRecorder() + + s.getNote(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestDeleteNote() { - tests := []struct { - name string - expectedCode int - err error - isLocked bool - }{ - { - name: "Delete Note when board is unlocked", - expectedCode: http.StatusNoContent, - isLocked: true, - }, - { - name: "Delete Note when board is locked", - expectedCode: http.StatusBadRequest, - err: &common.APIError{ - Err: errors.New("not allowed to edit a locked board"), - StatusCode: http.StatusBadRequest, - StatusText: "Bad request", - ErrorText: "something", - }, - isLocked: false, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { - s := new(Server) - - noteMock := services.NewMockNotes(suite.T()) - boardMock := services.NewMockBoards(suite.T()) - sessionMock := services.NewMockBoardSessions(suite.T()) - - s.notes = noteMock - s.boards = boardMock - s.sessions = sessionMock - - boardID, _ := uuid.NewRandom() - userID, _ := uuid.NewRandom() - noteID, _ := uuid.NewRandom() - - r := chi.NewRouter() - s.initNoteResources(r) - - req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) - req.req = logger.InitTestLoggerRequest(req.Request()) - rctx := chi.NewRouteContext() - rctx.URLParams.Add("id", boardID.String()) - req.AddToContext(chi.RouteCtxKey, rctx) - req.AddToContext(identifiers.UserIdentifier, userID) - - boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ - ID: boardID, - IsLocked: tt.isLocked, - }, nil) - - // Mock the SessionExists method - sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) - - // Mock the ModeratorSessionExists method - sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) - - // Mock the ParticipantBanned method - sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) - - if tt.isLocked { - noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) - } else { - noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) - } - - rr := httptest.NewRecorder() - r.ServeHTTP(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - boardMock.AssertExpectations(suite.T()) - sessionMock.AssertExpectations(suite.T()) - }) - } + tests := []struct { + name string + expectedCode int + err error + isLocked bool + }{ + { + name: "Delete Note when board is unlocked", + expectedCode: http.StatusNoContent, + isLocked: true, + }, + { + name: "Delete Note when board is locked", + expectedCode: http.StatusBadRequest, + err: &common.APIError{ + Err: errors.New("not allowed to edit a locked board"), + StatusCode: http.StatusBadRequest, + StatusText: "Bad request", + ErrorText: "something", + }, + isLocked: false, + }, + } + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + + noteMock := services.NewMockNotes(suite.T()) + boardMock := services.NewMockBoards(suite.T()) + sessionMock := services.NewMockBoardSessions(suite.T()) + + s.notes = noteMock + s.boards = boardMock + s.sessions = sessionMock + + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + noteID, _ := uuid.NewRandom() + + r := chi.NewRouter() + s.initNoteResources(r) + + req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) + req.req = logger.InitTestLoggerRequest(req.Request()) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + req.AddToContext(identifiers.UserIdentifier, userID) + + boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ + ID: boardID, + IsLocked: tt.isLocked, + }, nil) + + // Mock the SessionExists method + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) + + // Mock the ModeratorSessionExists method + sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) + + // Mock the ParticipantBanned method + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) + + if tt.isLocked { + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) + } else { + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) + } + + rr := httptest.NewRecorder() + r.ServeHTTP(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) + sessionMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *NotesTestSuite) TestEditNote() { + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusOK, nil, false, false, nil). + Append("api err", http.StatusForbidden, &common.APIError{ + Err: errors.New("test"), + StatusCode: http.StatusForbidden, + StatusText: "no", + ErrorText: "way", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + noteMock := services.NewMockNotes(suite.T()) + updatedText := "This note has been edited" + + boardId, _ := uuid.NewRandom() + noteId, _ := uuid.NewRandom() + + s.notes = noteMock + + req := NewTestRequestBuilder("PUT", fmt.Sprintf("/notes/%s", noteId.String()), strings.NewReader(fmt.Sprintf(`{ + "text": "%s"}`, updatedText))) + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.NoteIdentifier, noteId) + + noteMock.EXPECT().Update(req.req.Context(), dto.NoteUpdateRequest{ + Text: &updatedText, + Position: nil, + Edited: false, + ID: noteId, + Board: boardId, + }).Return(¬es.Note{ + Text: updatedText, + }, tt.err) + + rr := httptest.NewRecorder() + + s.updateNote(rr, req.Request()) + + buf := new(bytes.Buffer) + buf.ReadFrom(rr.Result().Body) + note := new(notes.Note) + json.Unmarshal(buf.Bytes(), ¬e) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + if tt.err == nil { + suite.Equal(updatedText, note.Text) + } + noteMock.AssertExpectations(suite.T()) + }) + } } From 747a38ab74e95ad7692e1b7b1fc81007cf6277ac Mon Sep 17 00:00:00 2001 From: Mateo Ivankovic Date: Mon, 17 Feb 2025 09:05:58 +0100 Subject: [PATCH 25/27] add edit-note test --- server/src/api/notes_test.go | 448 +++++++++++++++++------------------ 1 file changed, 224 insertions(+), 224 deletions(-) diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index 6afe88f49c..6593e35090 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -1,252 +1,252 @@ package api import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "github.com/go-chi/chi/v5" - "github.com/google/uuid" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/suite" - "net/http" - "net/http/httptest" - "scrumlr.io/server/common" - "scrumlr.io/server/common/dto" - "scrumlr.io/server/identifiers" - "scrumlr.io/server/logger" - "scrumlr.io/server/mocks/services" - "scrumlr.io/server/notes" - "strings" - "testing" + "bytes" + "encoding/json" + "errors" + "fmt" + "github.com/go-chi/chi/v5" + "github.com/google/uuid" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/identifiers" + "scrumlr.io/server/logger" + "scrumlr.io/server/mocks/services" + "scrumlr.io/server/notes" + "strings" + "testing" ) type NotesTestSuite struct { - suite.Suite + suite.Suite } func TestNotesTestSuite(t *testing.T) { - suite.Run(t, new(NotesTestSuite)) + suite.Run(t, new(NotesTestSuite)) } func (suite *NotesTestSuite) TestCreateNote() { - 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()) - testText := "asdf" - - boardId, _ := uuid.NewRandom() - userId, _ := uuid.NewRandom() - colId, _ := uuid.NewRandom() - - s.notes = noteMock - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ + 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()) + testText := "asdf" + + boardId, _ := uuid.NewRandom() + userId, _ := uuid.NewRandom() + colId, _ := uuid.NewRandom() + + s.notes = noteMock + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ "column": "%s", "text" : "%s" }`, colId.String(), testText))) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). - AddToContext(identifiers.UserIdentifier, userId) - - noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ - Board: boardId, - User: userId, - Text: testText, - Column: colId, - }).Return(¬es.Note{ - Text: testText, - }, tt.err) - - rr := httptest.NewRecorder() - - s.createNote(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - }) - } + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.UserIdentifier, userId) + + noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ + Board: boardId, + User: userId, + Text: testText, + Column: colId, + }).Return(¬es.Note{ + Text: testText, + }, tt.err) + + rr := httptest.NewRecorder() + + s.createNote(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestGetNote() { - 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()) - s.notes = noteMock - - noteID, _ := uuid.NewRandom() - - req := NewTestRequestBuilder("GET", "/", nil). - AddToContext(identifiers.NoteIdentifier, noteID) - - noteMock.EXPECT().Get(req.req.Context(), noteID).Return(¬es.Note{ - ID: noteID, - }, tt.err) - - rr := httptest.NewRecorder() - - s.getNote(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - }) - } + 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()) + s.notes = noteMock + + noteID, _ := uuid.NewRandom() + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.NoteIdentifier, noteID) + + noteMock.EXPECT().Get(req.req.Context(), noteID).Return(¬es.Note{ + ID: noteID, + }, tt.err) + + rr := httptest.NewRecorder() + + s.getNote(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestDeleteNote() { - tests := []struct { - name string - expectedCode int - err error - isLocked bool - }{ - { - name: "Delete Note when board is unlocked", - expectedCode: http.StatusNoContent, - isLocked: true, - }, - { - name: "Delete Note when board is locked", - expectedCode: http.StatusBadRequest, - err: &common.APIError{ - Err: errors.New("not allowed to edit a locked board"), - StatusCode: http.StatusBadRequest, - StatusText: "Bad request", - ErrorText: "something", - }, - isLocked: false, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { - s := new(Server) - - noteMock := services.NewMockNotes(suite.T()) - boardMock := services.NewMockBoards(suite.T()) - sessionMock := services.NewMockBoardSessions(suite.T()) - - s.notes = noteMock - s.boards = boardMock - s.sessions = sessionMock - - boardID, _ := uuid.NewRandom() - userID, _ := uuid.NewRandom() - noteID, _ := uuid.NewRandom() - - r := chi.NewRouter() - s.initNoteResources(r) - - req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) - req.req = logger.InitTestLoggerRequest(req.Request()) - rctx := chi.NewRouteContext() - rctx.URLParams.Add("id", boardID.String()) - req.AddToContext(chi.RouteCtxKey, rctx) - req.AddToContext(identifiers.UserIdentifier, userID) - - boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ - ID: boardID, - IsLocked: tt.isLocked, - }, nil) - - // Mock the SessionExists method - sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) - - // Mock the ModeratorSessionExists method - sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) - - // Mock the ParticipantBanned method - sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) - - if tt.isLocked { - noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) - } else { - noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) - } - - rr := httptest.NewRecorder() - r.ServeHTTP(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - boardMock.AssertExpectations(suite.T()) - sessionMock.AssertExpectations(suite.T()) - }) - } + tests := []struct { + name string + expectedCode int + err error + isLocked bool + }{ + { + name: "Delete Note when board is unlocked", + expectedCode: http.StatusNoContent, + isLocked: true, + }, + { + name: "Delete Note when board is locked", + expectedCode: http.StatusBadRequest, + err: &common.APIError{ + Err: errors.New("not allowed to edit a locked board"), + StatusCode: http.StatusBadRequest, + StatusText: "Bad request", + ErrorText: "something", + }, + isLocked: false, + }, + } + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + + noteMock := services.NewMockNotes(suite.T()) + boardMock := services.NewMockBoards(suite.T()) + sessionMock := services.NewMockBoardSessions(suite.T()) + + s.notes = noteMock + s.boards = boardMock + s.sessions = sessionMock + + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + noteID, _ := uuid.NewRandom() + + r := chi.NewRouter() + s.initNoteResources(r) + + req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) + req.req = logger.InitTestLoggerRequest(req.Request()) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + req.AddToContext(identifiers.UserIdentifier, userID) + + boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ + ID: boardID, + IsLocked: tt.isLocked, + }, nil) + + // Mock the SessionExists method + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) + + // Mock the ModeratorSessionExists method + sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) + + // Mock the ParticipantBanned method + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) + + if tt.isLocked { + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) + } else { + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) + } + + rr := httptest.NewRecorder() + r.ServeHTTP(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) + sessionMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestEditNote() { - testParameterBundles := *TestParameterBundles{}. - Append("all ok", http.StatusOK, nil, false, false, nil). - Append("api err", http.StatusForbidden, &common.APIError{ - Err: errors.New("test"), - StatusCode: http.StatusForbidden, - StatusText: "no", - ErrorText: "way", - }, false, false, nil) - - for _, tt := range testParameterBundles { - suite.Run(tt.name, func() { - s := new(Server) - noteMock := services.NewMockNotes(suite.T()) - updatedText := "This note has been edited" - - boardId, _ := uuid.NewRandom() - noteId, _ := uuid.NewRandom() - - s.notes = noteMock - - req := NewTestRequestBuilder("PUT", fmt.Sprintf("/notes/%s", noteId.String()), strings.NewReader(fmt.Sprintf(`{ + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusOK, nil, false, false, nil). + Append("api err", http.StatusForbidden, &common.APIError{ + Err: errors.New("test"), + StatusCode: http.StatusForbidden, + StatusText: "no", + ErrorText: "way", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + noteMock := services.NewMockNotes(suite.T()) + updatedText := "This note has been edited" + + boardId, _ := uuid.NewRandom() + noteId, _ := uuid.NewRandom() + + s.notes = noteMock + + req := NewTestRequestBuilder("PUT", fmt.Sprintf("/notes/%s", noteId.String()), strings.NewReader(fmt.Sprintf(`{ "text": "%s"}`, updatedText))) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). - AddToContext(identifiers.NoteIdentifier, noteId) - - noteMock.EXPECT().Update(req.req.Context(), dto.NoteUpdateRequest{ - Text: &updatedText, - Position: nil, - Edited: false, - ID: noteId, - Board: boardId, - }).Return(¬es.Note{ - Text: updatedText, - }, tt.err) - - rr := httptest.NewRecorder() - - s.updateNote(rr, req.Request()) - - buf := new(bytes.Buffer) - buf.ReadFrom(rr.Result().Body) - note := new(notes.Note) - json.Unmarshal(buf.Bytes(), ¬e) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - if tt.err == nil { - suite.Equal(updatedText, note.Text) - } - noteMock.AssertExpectations(suite.T()) - }) - } + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.NoteIdentifier, noteId) + + noteMock.EXPECT().Update(req.req.Context(), dto.NoteUpdateRequest{ + Text: &updatedText, + Position: nil, + Edited: false, + ID: noteId, + Board: boardId, + }).Return(¬es.Note{ + Text: updatedText, + }, tt.err) + + rr := httptest.NewRecorder() + + s.updateNote(rr, req.Request()) + + buf := new(bytes.Buffer) + buf.ReadFrom(rr.Result().Body) + note := new(notes.Note) + json.Unmarshal(buf.Bytes(), ¬e) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + if tt.err == nil { + suite.Equal(updatedText, note.Text) + } + noteMock.AssertExpectations(suite.T()) + }) + } } From 7a1c4c62572fd2cd0bd8c72d321c8dc3d90be83a Mon Sep 17 00:00:00 2001 From: Mateo Ivankovic Date: Mon, 17 Feb 2025 11:16:48 +0100 Subject: [PATCH 26/27] fix linter errors --- server/src/api/notes_test.go | 456 ++++++++++++++++++----------------- 1 file changed, 232 insertions(+), 224 deletions(-) diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index 6593e35090..4d97af235b 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -1,252 +1,260 @@ package api import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "github.com/go-chi/chi/v5" - "github.com/google/uuid" - "github.com/stretchr/testify/mock" - "github.com/stretchr/testify/suite" - "net/http" - "net/http/httptest" - "scrumlr.io/server/common" - "scrumlr.io/server/common/dto" - "scrumlr.io/server/identifiers" - "scrumlr.io/server/logger" - "scrumlr.io/server/mocks/services" - "scrumlr.io/server/notes" - "strings" - "testing" + "bytes" + "encoding/json" + "errors" + "fmt" + "github.com/go-chi/chi/v5" + "github.com/google/uuid" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" + "net/http" + "net/http/httptest" + "scrumlr.io/server/common" + "scrumlr.io/server/common/dto" + "scrumlr.io/server/identifiers" + "scrumlr.io/server/logger" + "scrumlr.io/server/mocks/services" + "scrumlr.io/server/notes" + "strings" + "testing" ) type NotesTestSuite struct { - suite.Suite + suite.Suite } func TestNotesTestSuite(t *testing.T) { - suite.Run(t, new(NotesTestSuite)) + suite.Run(t, new(NotesTestSuite)) } func (suite *NotesTestSuite) TestCreateNote() { - 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()) - testText := "asdf" - - boardId, _ := uuid.NewRandom() - userId, _ := uuid.NewRandom() - colId, _ := uuid.NewRandom() - - s.notes = noteMock - - req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ + 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()) + testText := "asdf" + + boardId, _ := uuid.NewRandom() + userId, _ := uuid.NewRandom() + colId, _ := uuid.NewRandom() + + s.notes = noteMock + + req := NewTestRequestBuilder("POST", "/", strings.NewReader(fmt.Sprintf(`{ "column": "%s", "text" : "%s" }`, colId.String(), testText))) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). - AddToContext(identifiers.UserIdentifier, userId) - - noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ - Board: boardId, - User: userId, - Text: testText, - Column: colId, - }).Return(¬es.Note{ - Text: testText, - }, tt.err) - - rr := httptest.NewRecorder() - - s.createNote(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - }) - } + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.UserIdentifier, userId) + + noteMock.EXPECT().Create(req.req.Context(), dto.NoteCreateRequest{ + Board: boardId, + User: userId, + Text: testText, + Column: colId, + }).Return(¬es.Note{ + Text: testText, + }, tt.err) + + rr := httptest.NewRecorder() + + s.createNote(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestGetNote() { - 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()) - s.notes = noteMock - - noteID, _ := uuid.NewRandom() - - req := NewTestRequestBuilder("GET", "/", nil). - AddToContext(identifiers.NoteIdentifier, noteID) - - noteMock.EXPECT().Get(req.req.Context(), noteID).Return(¬es.Note{ - ID: noteID, - }, tt.err) - - rr := httptest.NewRecorder() - - s.getNote(rr, req.Request()) - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - }) - } + 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()) + s.notes = noteMock + + noteID, _ := uuid.NewRandom() + + req := NewTestRequestBuilder("GET", "/", nil). + AddToContext(identifiers.NoteIdentifier, noteID) + + noteMock.EXPECT().Get(req.req.Context(), noteID).Return(¬es.Note{ + ID: noteID, + }, tt.err) + + rr := httptest.NewRecorder() + + s.getNote(rr, req.Request()) + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestDeleteNote() { - tests := []struct { - name string - expectedCode int - err error - isLocked bool - }{ - { - name: "Delete Note when board is unlocked", - expectedCode: http.StatusNoContent, - isLocked: true, - }, - { - name: "Delete Note when board is locked", - expectedCode: http.StatusBadRequest, - err: &common.APIError{ - Err: errors.New("not allowed to edit a locked board"), - StatusCode: http.StatusBadRequest, - StatusText: "Bad request", - ErrorText: "something", - }, - isLocked: false, - }, - } - for _, tt := range tests { - suite.Run(tt.name, func() { - s := new(Server) - - noteMock := services.NewMockNotes(suite.T()) - boardMock := services.NewMockBoards(suite.T()) - sessionMock := services.NewMockBoardSessions(suite.T()) - - s.notes = noteMock - s.boards = boardMock - s.sessions = sessionMock - - boardID, _ := uuid.NewRandom() - userID, _ := uuid.NewRandom() - noteID, _ := uuid.NewRandom() - - r := chi.NewRouter() - s.initNoteResources(r) - - req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) - req.req = logger.InitTestLoggerRequest(req.Request()) - rctx := chi.NewRouteContext() - rctx.URLParams.Add("id", boardID.String()) - req.AddToContext(chi.RouteCtxKey, rctx) - req.AddToContext(identifiers.UserIdentifier, userID) - - boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ - ID: boardID, - IsLocked: tt.isLocked, - }, nil) - - // Mock the SessionExists method - sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) - - // Mock the ModeratorSessionExists method - sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) - - // Mock the ParticipantBanned method - sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) - - if tt.isLocked { - noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) - } else { - noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) - } - - rr := httptest.NewRecorder() - r.ServeHTTP(rr, req.Request()) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - noteMock.AssertExpectations(suite.T()) - boardMock.AssertExpectations(suite.T()) - sessionMock.AssertExpectations(suite.T()) - }) - } + tests := []struct { + name string + expectedCode int + err error + isLocked bool + }{ + { + name: "Delete Note when board is unlocked", + expectedCode: http.StatusNoContent, + isLocked: true, + }, + { + name: "Delete Note when board is locked", + expectedCode: http.StatusBadRequest, + err: &common.APIError{ + Err: errors.New("not allowed to edit a locked board"), + StatusCode: http.StatusBadRequest, + StatusText: "Bad request", + ErrorText: "something", + }, + isLocked: false, + }, + } + for _, tt := range tests { + suite.Run(tt.name, func() { + s := new(Server) + + noteMock := services.NewMockNotes(suite.T()) + boardMock := services.NewMockBoards(suite.T()) + sessionMock := services.NewMockBoardSessions(suite.T()) + + s.notes = noteMock + s.boards = boardMock + s.sessions = sessionMock + + boardID, _ := uuid.NewRandom() + userID, _ := uuid.NewRandom() + noteID, _ := uuid.NewRandom() + + r := chi.NewRouter() + s.initNoteResources(r) + + req := NewTestRequestBuilder("DELETE", fmt.Sprintf("/notes/%s", noteID.String()), strings.NewReader(`{"deleteStack": false}`)) + req.req = logger.InitTestLoggerRequest(req.Request()) + rctx := chi.NewRouteContext() + rctx.URLParams.Add("id", boardID.String()) + req.AddToContext(chi.RouteCtxKey, rctx) + req.AddToContext(identifiers.UserIdentifier, userID) + + boardMock.EXPECT().Get(mock.Anything, boardID).Return(&dto.Board{ + ID: boardID, + IsLocked: tt.isLocked, + }, nil) + + // Mock the SessionExists method + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) + + // Mock the ModeratorSessionExists method + sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) + + // Mock the ParticipantBanned method + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, nil) + + if tt.isLocked { + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(nil) + } else { + noteMock.EXPECT().Delete(mock.Anything, dto.NoteDeleteRequest{DeleteStack: false}, noteID).Return(tt.err) + } + + rr := httptest.NewRecorder() + r.ServeHTTP(rr, req.Request()) + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + noteMock.AssertExpectations(suite.T()) + boardMock.AssertExpectations(suite.T()) + sessionMock.AssertExpectations(suite.T()) + }) + } } func (suite *NotesTestSuite) TestEditNote() { - testParameterBundles := *TestParameterBundles{}. - Append("all ok", http.StatusOK, nil, false, false, nil). - Append("api err", http.StatusForbidden, &common.APIError{ - Err: errors.New("test"), - StatusCode: http.StatusForbidden, - StatusText: "no", - ErrorText: "way", - }, false, false, nil) - - for _, tt := range testParameterBundles { - suite.Run(tt.name, func() { - s := new(Server) - noteMock := services.NewMockNotes(suite.T()) - updatedText := "This note has been edited" - - boardId, _ := uuid.NewRandom() - noteId, _ := uuid.NewRandom() - - s.notes = noteMock - - req := NewTestRequestBuilder("PUT", fmt.Sprintf("/notes/%s", noteId.String()), strings.NewReader(fmt.Sprintf(`{ + testParameterBundles := *TestParameterBundles{}. + Append("all ok", http.StatusOK, nil, false, false, nil). + Append("api err", http.StatusForbidden, &common.APIError{ + Err: errors.New("test"), + StatusCode: http.StatusForbidden, + StatusText: "no", + ErrorText: "way", + }, false, false, nil) + + for _, tt := range testParameterBundles { + suite.Run(tt.name, func() { + s := new(Server) + noteMock := services.NewMockNotes(suite.T()) + updatedText := "This note has been edited" + + boardId, _ := uuid.NewRandom() + noteId, _ := uuid.NewRandom() + + s.notes = noteMock + + req := NewTestRequestBuilder("PUT", fmt.Sprintf("/notes/%s", noteId.String()), strings.NewReader(fmt.Sprintf(`{ "text": "%s"}`, updatedText))) - req.req = logger.InitTestLoggerRequest(req.Request()) - req.AddToContext(identifiers.BoardIdentifier, boardId). - AddToContext(identifiers.NoteIdentifier, noteId) - - noteMock.EXPECT().Update(req.req.Context(), dto.NoteUpdateRequest{ - Text: &updatedText, - Position: nil, - Edited: false, - ID: noteId, - Board: boardId, - }).Return(¬es.Note{ - Text: updatedText, - }, tt.err) - - rr := httptest.NewRecorder() - - s.updateNote(rr, req.Request()) - - buf := new(bytes.Buffer) - buf.ReadFrom(rr.Result().Body) - note := new(notes.Note) - json.Unmarshal(buf.Bytes(), ¬e) - - suite.Equal(tt.expectedCode, rr.Result().StatusCode) - if tt.err == nil { - suite.Equal(updatedText, note.Text) - } - noteMock.AssertExpectations(suite.T()) - }) - } + req.req = logger.InitTestLoggerRequest(req.Request()) + req.AddToContext(identifiers.BoardIdentifier, boardId). + AddToContext(identifiers.NoteIdentifier, noteId) + + noteMock.EXPECT().Update(req.req.Context(), dto.NoteUpdateRequest{ + Text: &updatedText, + Position: nil, + Edited: false, + ID: noteId, + Board: boardId, + }).Return(¬es.Note{ + Text: updatedText, + }, tt.err) + + rr := httptest.NewRecorder() + + s.updateNote(rr, req.Request()) + + // parse response to Note + buf := new(bytes.Buffer) + _, err := buf.ReadFrom(rr.Result().Body) + if err != nil { + return + } + note := new(notes.Note) + err = json.Unmarshal(buf.Bytes(), ¬e) + if err != nil { + return + } + + suite.Equal(tt.expectedCode, rr.Result().StatusCode) + if tt.err == nil { + suite.Equal(updatedText, note.Text) + } + noteMock.AssertExpectations(suite.T()) + + }) + } } From 1ce338d6721c452aca9412ce54f291b17d161a02 Mon Sep 17 00:00:00 2001 From: Mateo Ivankovic Date: Mon, 17 Feb 2025 11:31:11 +0100 Subject: [PATCH 27/27] let test fail if not able to parse response --- server/src/api/notes_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index 4d97af235b..09f1fa5dec 100644 --- a/server/src/api/notes_test.go +++ b/server/src/api/notes_test.go @@ -241,12 +241,12 @@ func (suite *NotesTestSuite) TestEditNote() { buf := new(bytes.Buffer) _, err := buf.ReadFrom(rr.Result().Body) if err != nil { - return + suite.Fail("could not read response body") } note := new(notes.Note) err = json.Unmarshal(buf.Bytes(), ¬e) if err != nil { - return + suite.Fail("could not unmarshal response body") } suite.Equal(tt.expectedCode, rr.Result().StatusCode)