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>
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package request
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mattermost/mattermost/server/public/model"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestContext_WithSession(t *testing.T) {
|
|
t.Run("returns new context with empty session when session is nil", func(t *testing.T) {
|
|
originalCtx := TestContext(t)
|
|
|
|
newCtx := originalCtx.WithSession(nil)
|
|
|
|
require.NotNil(t, newCtx)
|
|
assert.NotSame(t, originalCtx, newCtx, "should return a new context instance")
|
|
assert.Empty(t, newCtx.Session().Id)
|
|
assert.Empty(t, newCtx.Session().UserId)
|
|
assert.Empty(t, newCtx.Session().Token)
|
|
})
|
|
|
|
t.Run("returns new context when session is provided", func(t *testing.T) {
|
|
originalCtx := TestContext(t)
|
|
session := &model.Session{
|
|
Id: "session-id",
|
|
UserId: "user-id",
|
|
Token: "token",
|
|
}
|
|
|
|
newCtx := originalCtx.WithSession(session)
|
|
|
|
require.NotNil(t, newCtx)
|
|
assert.NotSame(t, originalCtx, newCtx, "should return a new context instance")
|
|
|
|
assert.Equal(t, "session-id", newCtx.Session().Id)
|
|
assert.Equal(t, "user-id", newCtx.Session().UserId)
|
|
assert.Equal(t, "token", newCtx.Session().Token)
|
|
|
|
assert.Empty(t, originalCtx.Session().Id)
|
|
})
|
|
}
|