mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
The server module named github.com/hanzoai/team/server/v8 — a path that resolves to the retired workspace's repository, not this one — while server/public still published github.com/mattermost/mattermost/server/public. Both are github.com/hanzoteam/server/... now, which is where this code actually lives. That second half is what made the binary unbootable. Upstream's public path stayed claimed by upstream, mattermost-plugin-ai imported it, and the build linked public/model twice; public/plugin's gob.Register then ran twice under one name and panicked at init, before main. Reverting the rename traded the brand for a working binary. Rebranding the plugin alongside it needs no such trade: the agents fork is github.com/hanzoteam/agents/v2 against our public module, so no module named mattermost/mattermost is in the graph at all. Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and it is ours.
73 lines
2.2 KiB
Go
73 lines
2.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package request
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hanzoteam/server/server/public/model"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestContext_WithConnectionId(t *testing.T) {
|
|
t.Run("returns new context with connection id", func(t *testing.T) {
|
|
originalCtx := TestContext(t)
|
|
connectionId := "test-connection-id-123"
|
|
|
|
newCtx := originalCtx.WithConnectionId(connectionId)
|
|
|
|
require.NotNil(t, newCtx)
|
|
assert.NotSame(t, originalCtx, newCtx, "should return a new context instance")
|
|
assert.Equal(t, connectionId, newCtx.ConnectionId())
|
|
assert.Empty(t, originalCtx.ConnectionId(), "original context should remain unchanged")
|
|
})
|
|
|
|
t.Run("returns new context with empty connection id", func(t *testing.T) {
|
|
originalCtx := TestContext(t)
|
|
originalCtx = originalCtx.WithConnectionId("existing-id").(*Context)
|
|
|
|
newCtx := originalCtx.WithConnectionId("")
|
|
|
|
require.NotNil(t, newCtx)
|
|
assert.NotSame(t, originalCtx, newCtx, "should return a new context instance")
|
|
assert.Empty(t, newCtx.ConnectionId())
|
|
assert.Equal(t, "existing-id", originalCtx.ConnectionId(), "original context should remain unchanged")
|
|
})
|
|
}
|
|
|
|
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)
|
|
})
|
|
}
|