createParentChildChats creates a parent and child chat pair for subagent tests. The child starts in pending status.
( ctx context.Context, t *testing.T, server *Server, user database.User, org database.Organization, model database.ChatModelConfig, )
| 3008 | // createParentChildChats creates a parent and child chat pair for |
| 3009 | // subagent tests. The child starts in pending status. |
| 3010 | func createParentChildChats( |
| 3011 | ctx context.Context, |
| 3012 | t *testing.T, |
| 3013 | server *Server, |
| 3014 | user database.User, |
| 3015 | org database.Organization, |
| 3016 | model database.ChatModelConfig, |
| 3017 | ) (parent database.Chat, child database.Chat) { |
| 3018 | t.Helper() |
| 3019 | |
| 3020 | parent, err := server.CreateChat(ctx, CreateOptions{ |
| 3021 | OrganizationID: org.ID, |
| 3022 | OwnerID: user.ID, |
| 3023 | Title: "parent-" + t.Name(), |
| 3024 | ModelConfigID: model.ID, |
| 3025 | InitialUserContent: []codersdk.ChatMessagePart{codersdk.ChatMessageText("hello")}, |
| 3026 | }) |
| 3027 | require.NoError(t, err) |
| 3028 | |
| 3029 | child, err = server.CreateChat(ctx, CreateOptions{ |
| 3030 | OrganizationID: org.ID, |
| 3031 | OwnerID: user.ID, |
| 3032 | ParentChatID: uuid.NullUUID{ |
| 3033 | UUID: parent.ID, |
| 3034 | Valid: true, |
| 3035 | }, |
| 3036 | RootChatID: uuid.NullUUID{ |
| 3037 | UUID: parent.ID, |
| 3038 | Valid: true, |
| 3039 | }, |
| 3040 | Title: "child-" + t.Name(), |
| 3041 | ModelConfigID: model.ID, |
| 3042 | InitialUserContent: []codersdk.ChatMessagePart{codersdk.ChatMessageText("do work")}, |
| 3043 | }) |
| 3044 | require.NoError(t, err) |
| 3045 | |
| 3046 | return parent, child |
| 3047 | } |
| 3048 | |
| 3049 | // setChatStatus transitions a chat to the given status. |
| 3050 | func setChatStatus( |
no test coverage detected