mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-08 15:06:08 +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>
117 lines
3.0 KiB
Go
117 lines
3.0 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package boards
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/golang/mock/gomock"
|
|
"github.com/mattermost/focalboard/server/integrationtests"
|
|
"github.com/mattermost/focalboard/server/model"
|
|
"github.com/mattermost/focalboard/server/server"
|
|
"github.com/mattermost/focalboard/server/ws"
|
|
|
|
mockservicesapi "github.com/mattermost/focalboard/server/model/mocks"
|
|
|
|
serverModel "github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
type TestHelper struct {
|
|
Server *server.Server
|
|
}
|
|
|
|
func SetupTestHelper(t *testing.T) (*TestHelper, func()) {
|
|
th := &TestHelper{}
|
|
th.Server = newTestServer()
|
|
|
|
err := th.Server.Start()
|
|
require.NoError(t, err, "Server start should not error")
|
|
|
|
tearDown := func() {
|
|
err := th.Server.Shutdown()
|
|
require.NoError(t, err, "Server shutdown should not error")
|
|
}
|
|
return th, tearDown
|
|
}
|
|
|
|
func newTestServer() *server.Server {
|
|
return integrationtests.NewTestServerPluginMode()
|
|
}
|
|
func TestConfigurationNullConfiguration(t *testing.T) {
|
|
boardsApp := &BoardsApp{}
|
|
assert.NotNil(t, boardsApp.getConfiguration())
|
|
}
|
|
|
|
func TestOnConfigurationChange(t *testing.T) {
|
|
stringRef := ""
|
|
|
|
basePlugins := make(map[string]map[string]interface{})
|
|
basePlugins[PluginName] = make(map[string]interface{})
|
|
basePlugins[PluginName][SharedBoardsName] = true
|
|
|
|
basePluginSettings := &serverModel.PluginSettings{
|
|
Directory: &stringRef,
|
|
Plugins: basePlugins,
|
|
}
|
|
intRef := 365
|
|
baseDataRetentionSettings := &serverModel.DataRetentionSettings{
|
|
BoardsRetentionDays: &intRef,
|
|
}
|
|
usernameRef := "username"
|
|
baseTeamSettings := &serverModel.TeamSettings{
|
|
TeammateNameDisplay: &usernameRef,
|
|
}
|
|
|
|
falseRef := false
|
|
basePrivacySettings := &serverModel.PrivacySettings{
|
|
ShowEmailAddress: &falseRef,
|
|
ShowFullName: &falseRef,
|
|
}
|
|
|
|
baseConfig := &serverModel.Config{
|
|
PluginSettings: *basePluginSettings,
|
|
DataRetentionSettings: *baseDataRetentionSettings,
|
|
TeamSettings: *baseTeamSettings,
|
|
PrivacySettings: *basePrivacySettings,
|
|
}
|
|
|
|
t.Run("Test Load Plugin Success", func(t *testing.T) {
|
|
th, tearDown := SetupTestHelper(t)
|
|
defer tearDown()
|
|
|
|
ctrl := gomock.NewController(t)
|
|
api := mockservicesapi.NewMockServicesAPI(ctrl)
|
|
api.EXPECT().GetConfig().Return(baseConfig)
|
|
|
|
b := &BoardsApp{
|
|
server: th.Server,
|
|
wsPluginAdapter: &FakePluginAdapter{},
|
|
servicesAPI: api,
|
|
logger: mlog.CreateConsoleTestLogger(&testing.T{}),
|
|
}
|
|
|
|
err := b.OnConfigurationChange()
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, 1, count)
|
|
|
|
// make sure both App and Server got updated
|
|
assert.True(t, b.server.Config().EnablePublicSharedBoards)
|
|
assert.True(t, b.server.App().GetClientConfig().EnablePublicSharedBoards)
|
|
})
|
|
}
|
|
|
|
var count = 0
|
|
|
|
type FakePluginAdapter struct {
|
|
ws.PluginAdapter
|
|
}
|
|
|
|
func (c *FakePluginAdapter) BroadcastConfigChange(clientConfig model.ClientConfig) {
|
|
count++
|
|
}
|