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

Function createParentChildChats

coderd/x/chatd/subagent_internal_test.go:3010–3047  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

3008// createParentChildChats creates a parent and child chat pair for
3009// subagent tests. The child starts in pending status.
3010func 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.
3050func setChatStatus(

Calls 4

ChatMessageTextFunction · 0.92
HelperMethod · 0.65
CreateChatMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected