1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-02-04 19:15:49 +02:00

Fix mock early finish issue on test helpers (#3374)

This commit is contained in:
Miguel de la Cruz 2022-07-15 14:34:36 +02:00 committed by GitHub
parent a3a753591e
commit 3d753a15e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 16 deletions

View File

@ -26,7 +26,6 @@ func SetupTestHelperMockStore(t *testing.T) *TestHelperMockStore {
th := &TestHelperMockStore{} th := &TestHelperMockStore{}
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockStore := mockstore.NewMockStore(ctrl) mockStore := mockstore.NewMockStore(ctrl)
th.Server = newTestServerMock(mockStore) th.Server = newTestServerMock(mockStore)

View File

@ -179,7 +179,6 @@ func TestUndeleteBlock(t *testing.T) {
gomock.Eq(model.QueryBlockHistoryOptions{Limit: 1, Descending: true}), gomock.Eq(model.QueryBlockHistoryOptions{Limit: 1, Descending: true}),
).Return([]model.Block{block}, nil) ).Return([]model.Block{block}, nil)
th.Store.EXPECT().UndeleteBlock(gomock.Eq("block-id"), gomock.Eq("user-id-1")).Return(blockError{"error"}) th.Store.EXPECT().UndeleteBlock(gomock.Eq("block-id"), gomock.Eq("user-id-1")).Return(blockError{"error"})
th.Store.EXPECT().GetBlock(gomock.Eq("block-id")).Return(&block, nil)
_, err := th.App.UndeleteBlock("block-id", "user-id-1") _, err := th.App.UndeleteBlock("block-id", "user-id-1")
require.Error(t, err, "error") require.Error(t, err, "error")
}) })
@ -343,8 +342,6 @@ func TestInsertBlocks(t *testing.T) {
} }
board := &model.Board{ID: boardID} board := &model.Board{ID: boardID}
th.Store.EXPECT().GetBoard(boardID).Return(board, nil) th.Store.EXPECT().GetBoard(boardID).Return(board, nil)
th.Store.EXPECT().InsertBlock(&block, "user-id-1").Return(nil)
th.Store.EXPECT().GetMembersForBoard(boardID).Return([]*model.BoardMember{}, nil)
// setting up mocks for limits // setting up mocks for limits
fakeLicense := &mmModel.License{ fakeLicense := &mmModel.License{

View File

@ -240,7 +240,6 @@ func TestSaveFile(t *testing.T) {
mockedFileBackend := &mocks.FileBackend{} mockedFileBackend := &mocks.FileBackend{}
th.App.filesBackend = mockedFileBackend th.App.filesBackend = mockedFileBackend
mockedError := &TestError{} mockedError := &TestError{}
th.Store.EXPECT().SaveFileInfo(gomock.Any()).Return(nil)
writeFileFunc := func(reader io.Reader, path string) int64 { writeFileFunc := func(reader io.Reader, path string) int64 {
paths := strings.Split(path, string(os.PathSeparator)) paths := strings.Split(path, string(os.PathSeparator))

View File

@ -27,7 +27,6 @@ type TestHelper struct {
func SetupTestHelper(t *testing.T) (*TestHelper, func()) { func SetupTestHelper(t *testing.T) (*TestHelper, func()) {
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
defer ctrl.Finish()
cfg := config.Configuration{} cfg := config.Configuration{}
store := mockstore.NewMockStore(ctrl) store := mockstore.NewMockStore(ctrl)
filesBackend := &mocks.FileBackend{} filesBackend := &mocks.FileBackend{}

View File

@ -57,6 +57,7 @@ func TestGetRootTeam(t *testing.T) {
th, tearDown := SetupTestHelper(t) th, tearDown := SetupTestHelper(t)
defer tearDown() defer tearDown()
th.Store.EXPECT().GetTeam("0").Return(tc.teamToReturnBeforeUpsert, nil) th.Store.EXPECT().GetTeam("0").Return(tc.teamToReturnBeforeUpsert, nil)
if tc.teamToReturnBeforeUpsert == nil {
th.Store.EXPECT().UpsertTeamSignupToken(gomock.Any()).DoAndReturn( th.Store.EXPECT().UpsertTeamSignupToken(gomock.Any()).DoAndReturn(
func(arg0 model.Team) error { func(arg0 model.Team) error {
if tc.isError { if tc.isError {
@ -65,6 +66,7 @@ func TestGetRootTeam(t *testing.T) {
th.Store.EXPECT().GetTeam("0").Return(tc.teamToReturnAfterUpsert, nil) th.Store.EXPECT().GetTeam("0").Return(tc.teamToReturnAfterUpsert, nil)
return nil return nil
}) })
}
rootTeam, err := th.App.GetRootTeam() rootTeam, err := th.App.GetRootTeam()
if tc.isError { if tc.isError {

View File

@ -32,9 +32,7 @@ var mockSession = &model.Session{
func setupTestHelper(t *testing.T) *TestHelper { func setupTestHelper(t *testing.T) *TestHelper {
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
defer ctrl.Finish()
ctrlPermissions := gomock.NewController(t) ctrlPermissions := gomock.NewController(t)
defer ctrlPermissions.Finish()
cfg := config.Configuration{} cfg := config.Configuration{}
mockStore := mockstore.NewMockStore(ctrl) mockStore := mockstore.NewMockStore(ctrl)
mockPermissions := mockpermissions.NewMockStore(ctrlPermissions) mockPermissions := mockpermissions.NewMockStore(ctrlPermissions)