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 new file mode 100644 index 0000000000..26372fde54 --- /dev/null +++ b/server/src/.mockery.yaml @@ -0,0 +1,20 @@ +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: + # configuration on interface level + interfaces: + Boards: + all: true + BoardSessions: + all: true + Notes: + all: true + Votings: + all: true 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..69da450fa5 --- /dev/null +++ b/server/src/api/boards_test.go @@ -0,0 +1,452 @@ +package api + +import ( + "errors" + "fmt" + "github.com/go-chi/chi/v5" + "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" + "time" +) + +type BoardTestSuite struct { + suite.Suite +} + +func TestBoardTestSuite(t *testing.T) { + suite.Run(t, new(BoardTestSuite)) +} + +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, + } +} + +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) + boardMock := services.NewMockBoards(suite.T()) + + s.boards = boardMock + accessPolicy := types.AccessPolicyPublic + visible := true + colName := "Lean Coffee" + color := types.Color("backlog-blue") + ownerID := uuid.New() + + 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, + Passphrase: nil, + Columns: []dto.ColumnRequest{ + { + Name: colName, + Color: color, + Visible: &visible, + Index: nil, + Board: uuid.Nil, + User: uuid.Nil, + }, + }, + Owner: ownerID, + }).Return(suite.createBoard(nil, nil, accessPolicy, nil, nil), te.err) + + rr := httptest.NewRecorder() + + s.createBoard(rr, req.Request()) + + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestDeleteBoard() { + + 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) + 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(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestGetBoards() { + + 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) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + userID := uuid.New() + + boardName := "Test Name" + boardDescription := "Test Description" + firstBoard := suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil) + + boardName = "Test Board" + boardDescription = "Description for second board" + secondBoard := suite.createBoard(&boardName, &boardDescription, types.AccessPolicyPublic, nil, nil) + boardIDs := []uuid.UUID{firstBoard.ID, secondBoard.ID} + + 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{}, + Participants: 3, + }, + { + Board: secondBoard, + Columns: 2, + CreatedAt: time.Time{}, + Participants: 4, + }, + }, te.err) + } + + rr := httptest.NewRecorder() + + s.getBoards(rr, req.Request()) + + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestGetBoard() { + + 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) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() + + boardName := "Test Name" + boardDescription := "Test Description" + 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(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestJoinBoard() { + boardName := "Test Name" + boardDescription := "Test Description" + salt := "z9YcpBno6azI2ueA" + passphrase := common.Sha512BySalt("123", salt) + + 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", + }, 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) + 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) + + if te.sessionExists { + sessionMock.EXPECT().ParticipantBanned(req.req.Context(), boardID, userID).Return(false, te.err) + } else { + boardMock.EXPECT().Get(req.req.Context(), boardID).Return(te.board, te.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 !te.sessionExists { + sessionMock.EXPECT().Create(req.req.Context(), boardID, userID).Return(new(dto.BoardSession), te.err) + } + + } + + rr := httptest.NewRecorder() + + s.joinBoard(rr, req.Request()) + + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + sessionMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestUpdateBoards() { + + 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) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() + + newName := "UpdatedName" + newDescription := "UpdatedDescription" + accessPolicy := types.AccessPolicyPublic + boardReq := dto.BoardUpdateRequest{ + Name: &newName, + Description: &newDescription, + AccessPolicy: &accessPolicy, + ID: boardID, + } + + 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) + + boardMock.EXPECT().Update(req.req.Context(), boardReq).Return(new(dto.Board), te.err) + + rr := httptest.NewRecorder() + + s.updateBoard(rr, req.Request()) + + suite.Equal(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestSetTimer() { + + 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) + boardMock := services.NewMockBoards(suite.T()) + s.boards = boardMock + boardID := uuid.New() + + minutes := uint8(4) + + 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(te.expectedCode, rr.Result().StatusCode) + boardMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestDeleteTimer() { + + 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) + 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) + boardMock.AssertExpectations(suite.T()) + }) + } +} + +func (suite *BoardTestSuite) TestIncrementTimer() { + + 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) + 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) + boardMock.AssertExpectations(suite.T()) + }) + } +} diff --git a/server/src/api/columns_test.go b/server/src/api/columns_test.go new file mode 100644 index 0000000000..cf4ca46287 --- /dev/null +++ b/server/src/api/columns_test.go @@ -0,0 +1,261 @@ +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" +) + +type ColumnTestSuite struct { + suite.Suite +} + +func TestColumnTestSuite(t *testing.T) { + 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()) + }) + } +} + +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()) + }) + } +} + +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()) + }) + } +} + +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()) + }) + } +} + +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()) + }) + } +} 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 diff --git a/server/src/api/notes_test.go b/server/src/api/notes_test.go index ec4cecda5c..eead457755 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(ctx, 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) - 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) - return args.Error(0) -} - -func (m *SessionsMock) Create(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSession, error) { - args := m.Called(ctx, 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) - 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) - 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) - 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) - 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) - return args.Error(0) -} - -func (m *SessionsMock) GetSessionRequest(ctx context.Context, boardID, userID uuid.UUID) (*dto.BoardSessionRequest, error) { - args := m.Called(ctx, 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) - 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) - 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) - 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) - 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) - 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 } @@ -139,121 +28,91 @@ 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) - 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()) }) } } 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) - 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()) }) } } func (suite *NotesTestSuite) TestDeleteNote() { + tests := []struct { name string expectedCode int @@ -280,49 +139,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", mock.Anything, boardID, userID).Return(true, nil) + sessionMock.EXPECT().SessionExists(req.req.Context(), boardID, userID).Return(true, nil) // Mock the ModeratorSessionExists method - sessionMock.On("ModeratorSessionExists", mock.Anything, boardID, userID).Return(true, nil) + sessionMock.EXPECT().ModeratorSessionExists(mock.Anything, boardID, userID).Return(true, nil) // Mock the ParticipantBanned method - sessionMock.On("ParticipantBanned", mock.Anything, 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, 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/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, + } +} 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_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_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_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_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 +}