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>
64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package sqlstore
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost/server/public/shared/request"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestContextMaster(t *testing.T) {
|
|
if enableFullyParallelTests {
|
|
t.Parallel()
|
|
}
|
|
|
|
ctx := context.Background()
|
|
|
|
m := WithMaster(ctx)
|
|
assert.True(t, HasMaster(m))
|
|
}
|
|
|
|
func TestRequestContextWithMaster(t *testing.T) {
|
|
if enableFullyParallelTests {
|
|
t.Parallel()
|
|
}
|
|
|
|
t.Run("set and get", func(t *testing.T) {
|
|
var rctx request.CTX = request.TestContext(t)
|
|
|
|
rctx = RequestContextWithMaster(rctx)
|
|
assert.True(t, HasMaster(rctx.Context()))
|
|
})
|
|
|
|
t.Run("values get copied from original context", func(t *testing.T) {
|
|
var rctx request.CTX = request.TestContext(t)
|
|
rctx = RequestContextWithMaster(rctx)
|
|
rctxCopy := rctx
|
|
|
|
assert.True(t, HasMaster(rctx.Context()))
|
|
assert.True(t, HasMaster(rctxCopy.Context()))
|
|
})
|
|
|
|
t.Run("directly assigning does not cause the copy to alter the original context", func(t *testing.T) {
|
|
var rctx request.CTX = request.TestContext(t)
|
|
rctxCopy := rctx
|
|
rctxCopy = RequestContextWithMaster(rctxCopy)
|
|
|
|
assert.False(t, HasMaster(rctx.Context()))
|
|
assert.True(t, HasMaster(rctxCopy.Context()))
|
|
})
|
|
|
|
t.Run("directly assigning does not cause the original context to alter the copy", func(t *testing.T) {
|
|
var rctx request.CTX = request.TestContext(t)
|
|
rctxCopy := rctx
|
|
rctx = RequestContextWithMaster(rctx)
|
|
|
|
assert.True(t, HasMaster(rctx.Context()))
|
|
assert.False(t, HasMaster(rctxCopy.Context()))
|
|
})
|
|
}
|