Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
61 lines
2.2 KiB
Go
61 lines
2.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDoSetupContentFlaggingProperties(t *testing.T) {
|
|
t.Run("should register property group and fields", func(t *testing.T) {
|
|
//we need to call the Setup method and run the full setup instead of
|
|
//just creating a new server via NewServer() because the Setup method
|
|
//also takes care of using the correct database DSN based on environment,
|
|
//settings, setting up the store and initializing services used in store such as property services.
|
|
th := Setup(t)
|
|
defer th.TearDown()
|
|
|
|
group, err := th.Server.propertyService.GetPropertyGroup(model.ContentFlaggingGroupName)
|
|
require.NoError(t, err)
|
|
require.NotNil(t, group)
|
|
require.Equal(t, model.ContentFlaggingGroupName, group.Name)
|
|
|
|
propertyFields, err := th.Server.propertyService.SearchPropertyFields(group.ID, model.PropertyFieldSearchOpts{PerPage: 100})
|
|
require.NoError(t, err)
|
|
require.Len(t, propertyFields, 11)
|
|
|
|
data, err := th.Store.System().GetByName(contentFlaggingSetupDoneKey)
|
|
require.NoError(t, err)
|
|
require.Equal(t, "v5", data.Value)
|
|
})
|
|
|
|
t.Run("the migration is idempotent", func(t *testing.T) {
|
|
th := Setup(t)
|
|
defer th.TearDown()
|
|
|
|
// Now we will remove the migration done key from systems table to allow the data migration to run again
|
|
_, err := th.Store.System().PermanentDeleteByName(contentFlaggingSetupDoneKey)
|
|
require.NoError(t, err)
|
|
|
|
// Run the content flagging data migration again
|
|
err = th.Server.doSetupContentFlaggingProperties()
|
|
require.NoError(t, err)
|
|
|
|
group, err := th.Server.propertyService.GetPropertyGroup(model.ContentFlaggingGroupName)
|
|
require.NoError(t, err)
|
|
require.Equal(t, model.ContentFlaggingGroupName, group.Name)
|
|
|
|
propertyFields, err := th.Server.propertyService.SearchPropertyFields(group.ID, model.PropertyFieldSearchOpts{PerPage: 100})
|
|
require.NoError(t, err)
|
|
require.Len(t, propertyFields, 11)
|
|
|
|
data, err := th.Store.System().GetByName(contentFlaggingSetupDoneKey)
|
|
require.NoError(t, err)
|
|
require.Equal(t, "v5", data.Value)
|
|
})
|
|
}
|