mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-24 08:22:29 +02:00
c8e729b6fe
* refactor: updated dependency for focalboard server * chore: more dependency fixes * refactor: removed the unless code * refactor: added ctx for login and removed unnessary code * refactor: bump up go version * refactor: removed the commented code * chore: upgraded golinter version * fix: linter issue * refactor: removed feature flg fix golinter * refactor: removed feature flag from code * revert: statistic and it's function * refactor: removed ProductLimit related code * refactor: removed isWithinViewsLimit implementation * refactor: moved function GetUsedCardsCount to statistics.go from cloud.go * refactor: removed insight code board * refactor: removed limit dialog * refactor: updated dependencies for linux * chore: golinter fix * chore: updated helper test function to use newLogger * fix: go test * refactor: db ping attempts from config * revert: feature in action * revert: feature flag in action * revert: boardsEditor setting --------- Co-authored-by: Rajat Dabade <rajat@Rajats-MacBook-Pro.local>
62 lines
1.9 KiB
Go
62 lines
1.9 KiB
Go
package ws
|
|
|
|
import (
|
|
"testing"
|
|
|
|
authMocks "github.com/mattermost/focalboard/server/auth/mocks"
|
|
wsMocks "github.com/mattermost/focalboard/server/ws/mocks"
|
|
|
|
mmModel "github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
|
|
"github.com/golang/mock/gomock"
|
|
)
|
|
|
|
type TestHelper struct {
|
|
api *wsMocks.MockAPI
|
|
auth *authMocks.MockAuthInterface
|
|
store *wsMocks.MockStore
|
|
ctrl *gomock.Controller
|
|
pa *PluginAdapter
|
|
}
|
|
|
|
func SetupTestHelper(t *testing.T) *TestHelper {
|
|
ctrl := gomock.NewController(t)
|
|
mockAPI := wsMocks.NewMockAPI(ctrl)
|
|
mockAuth := authMocks.NewMockAuthInterface(ctrl)
|
|
mockStore := wsMocks.NewMockStore(ctrl)
|
|
|
|
mockAPI.EXPECT().LogDebug(gomock.Any(), gomock.Any()).AnyTimes()
|
|
mockAPI.EXPECT().LogInfo(gomock.Any(), gomock.Any()).AnyTimes()
|
|
mockAPI.EXPECT().LogError(gomock.Any(), gomock.Any()).AnyTimes()
|
|
mockAPI.EXPECT().LogWarn(gomock.Any(), gomock.Any()).AnyTimes()
|
|
|
|
return &TestHelper{
|
|
api: mockAPI,
|
|
auth: mockAuth,
|
|
store: mockStore,
|
|
ctrl: ctrl,
|
|
pa: NewPluginAdapter(mockAPI, mockAuth, mockStore, mlog.CreateConsoleTestLogger(t)),
|
|
}
|
|
}
|
|
|
|
func (th *TestHelper) ReceiveWebSocketMessage(webConnID, userID, action string, data map[string]interface{}) {
|
|
req := &mmModel.WebSocketRequest{Action: websocketMessagePrefix + action, Data: data}
|
|
|
|
th.pa.WebSocketMessageHasBeenPosted(webConnID, userID, req)
|
|
}
|
|
|
|
func (th *TestHelper) SubscribeWebConnToTeam(webConnID, userID, teamID string) {
|
|
th.auth.EXPECT().
|
|
DoesUserHaveTeamAccess(userID, teamID).
|
|
Return(true)
|
|
|
|
msgData := map[string]interface{}{"teamId": teamID}
|
|
th.ReceiveWebSocketMessage(webConnID, userID, websocketActionSubscribeTeam, msgData)
|
|
}
|
|
|
|
func (th *TestHelper) UnsubscribeWebConnFromTeam(webConnID, userID, teamID string) {
|
|
msgData := map[string]interface{}{"teamId": teamID}
|
|
th.ReceiveWebSocketMessage(webConnID, userID, websocketActionUnsubscribeTeam, msgData)
|
|
}
|