MCPcopy Index your code
hub / github.com/coder/coder / TestChatDebugRun

Function TestChatDebugRun

coderd/exp_chats_test.go:12644–12776  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12642}
12643
12644func TestChatDebugRun(t *testing.T) {
12645 t.Parallel()
12646
12647 t.Run("ReturnsRunWithSteps", func(t *testing.T) {
12648 t.Parallel()
12649
12650 ctx := testutil.Context(t, testutil.WaitLong)
12651 client, db := newChatClientWithDatabase(t)
12652 firstUser := coderdtest.CreateFirstUser(t, client.Client)
12653 modelConfig := createChatModelConfig(t, client)
12654
12655 chat := dbgen.Chat(t, db, database.Chat{
12656 OrganizationID: firstUser.OrganizationID,
12657 OwnerID: firstUser.UserID,
12658 LastModelConfigID: modelConfig.ID,
12659 Title: "debug-run-detail",
12660 })
12661
12662 run := seedChatDebugRun(ctx, t, db, chat.ID, time.Now().UTC())
12663 firstStep := seedChatDebugStep(ctx, t, db, run, 1)
12664 secondStep := seedChatDebugStep(ctx, t, db, run, 2)
12665
12666 got, err := client.GetChatDebugRun(ctx, chat.ID, run.ID)
12667 require.NoError(t, err)
12668 require.Equal(t, run.ID, got.ID)
12669 require.Equal(t, chat.ID, got.ChatID)
12670 require.Equal(t, codersdk.ChatDebugRunKindChatTurn, got.Kind)
12671 require.Equal(t, codersdk.ChatDebugStatusInProgress, got.Status)
12672 require.NotNil(t, got.Provider)
12673 require.Equal(t, "openai", *got.Provider)
12674 require.Len(t, got.Steps, 2)
12675 require.Equal(t, firstStep.ID, got.Steps[0].ID)
12676 require.Equal(t, secondStep.ID, got.Steps[1].ID)
12677 require.Equal(t, codersdk.ChatDebugStepOperationStream, got.Steps[0].Operation)
12678 })
12679
12680 t.Run("ReturnsRunWithoutSteps", func(t *testing.T) {
12681 t.Parallel()
12682
12683 ctx := testutil.Context(t, testutil.WaitLong)
12684 client, db := newChatClientWithDatabase(t)
12685 firstUser := coderdtest.CreateFirstUser(t, client.Client)
12686 modelConfig := createChatModelConfig(t, client)
12687
12688 chat := dbgen.Chat(t, db, database.Chat{
12689 OrganizationID: firstUser.OrganizationID,
12690 OwnerID: firstUser.UserID,
12691 LastModelConfigID: modelConfig.ID,
12692 Title: "debug-run-empty",
12693 })
12694 run := seedChatDebugRun(ctx, t, db, chat.ID, time.Now().UTC())
12695
12696 got, err := client.GetChatDebugRun(ctx, chat.ID, run.ID)
12697 require.NoError(t, err)
12698 require.Equal(t, run.ID, got.ID)
12699 require.NotNil(t, got.Steps, "steps slice must be non-nil even when empty")
12700 require.Empty(t, got.Steps)
12701 })

Callers

nothing calls this directly

Calls 15

ContextFunction · 0.92
CreateFirstUserFunction · 0.92
ChatFunction · 0.92
seedChatDebugRunFunction · 0.85
seedChatDebugStepFunction · 0.85
requireSDKErrorFunction · 0.85
GetChatDebugRunMethod · 0.80
createChatModelConfigFunction · 0.70
RunMethod · 0.65
CloseMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected