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

Function TestSubmitToolResultsRejectsArchivedChat

coderd/x/chatd/chatd_test.go:9563–9602  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9561}
9562
9563func TestSubmitToolResultsRejectsArchivedChat(t *testing.T) {
9564 t.Parallel()
9565
9566 db, ps := dbtestutil.NewDB(t)
9567 replica := newTestServer(t, db, ps, uuid.New())
9568
9569 ctx := testutil.Context(t, testutil.WaitLong)
9570 user, org, model := seedChatDependencies(t, db)
9571
9572 chat, err := replica.CreateChat(ctx, chatd.CreateOptions{
9573 OwnerID: user.ID,
9574 OrganizationID: org.ID,
9575 Title: "submit-tool-archived",
9576 ModelConfigID: model.ID,
9577 InitialUserContent: []codersdk.ChatMessagePart{codersdk.ChatMessageText("hello")},
9578 })
9579 require.NoError(t, err)
9580
9581 err = replica.ArchiveChat(ctx, chat)
9582 require.NoError(t, err)
9583
9584 // Set requires_action so the test exercises a realistic
9585 // scenario where SubmitToolResults would be called.
9586 _, err = db.UpdateChatStatus(ctx, database.UpdateChatStatusParams{
9587 ID: chat.ID,
9588 Status: database.ChatStatusRequiresAction,
9589 })
9590 require.NoError(t, err)
9591
9592 err = replica.SubmitToolResults(ctx, chatd.SubmitToolResultsOptions{
9593 ChatID: chat.ID,
9594 UserID: user.ID,
9595 ModelConfigID: model.ID,
9596 Results: []codersdk.ToolResult{{
9597 ToolCallID: "fake-tool-call-id",
9598 Output: json.RawMessage(`{"result":"ignored"}`),
9599 }},
9600 })
9601 require.ErrorIs(t, err, chatd.ErrChatArchived)
9602}
9603
9604func TestAcquireChatsSkipsArchivedPendingChat(t *testing.T) {
9605 t.Parallel()

Callers

nothing calls this directly

Calls 10

NewDBFunction · 0.92
ContextFunction · 0.92
ChatMessageTextFunction · 0.92
ArchiveChatMethod · 0.80
newTestServerFunction · 0.70
seedChatDependenciesFunction · 0.70
NewMethod · 0.65
CreateChatMethod · 0.65
UpdateChatStatusMethod · 0.65
SubmitToolResultsMethod · 0.45

Tested by

no test coverage detected