Files
coder/coderd/x/chatd/chatdebug/context_test.go
Michael Suchacz 680b2f59cd refactor: remove obsolete chatd code and tests (#29228)
Chatd still carries an unreachable interruption flush path, unused state
and options, an uncalled workspace MCP cache invalidation callback, and
a stream-buffer-drop counter that production never increments. Remove
these paths and their dedicated assertions, and update the generated
metrics inventory and documentation.

Consolidate duplicate publication and rollback tests and move fixture
writers and test-only inspection helpers into test files. Retain the
interruption persistence, state-machine matrix, legacy message format,
and provider compatibility coverage.
2026-09-14 10:51:22 +02:00

50 lines
1.1 KiB
Go

package chatdebug_test
import (
"context"
"testing"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/coderd/x/chatd/chatdebug"
)
func TestContextWithRunRoundTrip(t *testing.T) {
t.Parallel()
rc := &chatdebug.RunContext{
RunID: uuid.New(),
ChatID: uuid.New(),
RootChatID: uuid.New(),
ParentChatID: uuid.New(),
ModelConfigID: uuid.New(),
TriggerMessageID: 11,
HistoryTipMessageID: 22,
Provider: "anthropic",
Model: "claude-sonnet",
}
ctx := chatdebug.ContextWithRun(context.Background(), rc)
got, ok := chatdebug.RunFromContext(ctx)
require.True(t, ok)
require.Same(t, rc, got)
require.Equal(t, *rc, *got)
}
func TestRunFromContextAbsent(t *testing.T) {
t.Parallel()
got, ok := chatdebug.RunFromContext(context.Background())
require.False(t, ok)
require.Nil(t, got)
}
func TestContextWithRunPanicsOnNil(t *testing.T) {
t.Parallel()
require.Panics(t, func() {
_ = chatdebug.ContextWithRun(context.Background(), nil)
})
}