(t *testing.T)
| 9561 | } |
| 9562 | |
| 9563 | func 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 | |
| 9604 | func TestAcquireChatsSkipsArchivedPendingChat(t *testing.T) { |
| 9605 | t.Parallel() |
nothing calls this directly
no test coverage detected