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

Function TestIsSubagentDescendant

coderd/x/chatd/subagent_internal_test.go:2867–3006  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2865}
2866
2867func TestIsSubagentDescendant(t *testing.T) {
2868 t.Parallel()
2869
2870 db, ps := dbtestutil.NewDB(t)
2871 server := newInternalTestServer(t, db, ps, chatprovider.ProviderAPIKeys{})
2872
2873 ctx := chatdTestContext(t)
2874 user, org, model := seedInternalChatDeps(t, db)
2875
2876 // Build a chain: root -> child -> grandchild.
2877 root, err := server.CreateChat(ctx, CreateOptions{
2878 OrganizationID: org.ID,
2879 OwnerID: user.ID,
2880 Title: "root",
2881 ModelConfigID: model.ID,
2882 InitialUserContent: []codersdk.ChatMessagePart{codersdk.ChatMessageText("root")},
2883 })
2884 require.NoError(t, err)
2885
2886 child, err := server.CreateChat(ctx, CreateOptions{
2887 OrganizationID: org.ID,
2888 OwnerID: user.ID,
2889 ParentChatID: uuid.NullUUID{
2890 UUID: root.ID,
2891 Valid: true,
2892 },
2893 RootChatID: uuid.NullUUID{
2894 UUID: root.ID,
2895 Valid: true,
2896 },
2897 Title: "child",
2898 ModelConfigID: model.ID,
2899 InitialUserContent: []codersdk.ChatMessagePart{codersdk.ChatMessageText("child")},
2900 })
2901 require.NoError(t, err)
2902
2903 grandchild, err := server.CreateChat(ctx, CreateOptions{
2904 OrganizationID: org.ID,
2905 OwnerID: user.ID,
2906 ParentChatID: uuid.NullUUID{
2907 UUID: child.ID,
2908 Valid: true,
2909 },
2910 RootChatID: uuid.NullUUID{
2911 UUID: root.ID,
2912 Valid: true,
2913 },
2914 Title: "grandchild",
2915 ModelConfigID: model.ID,
2916 InitialUserContent: []codersdk.ChatMessagePart{codersdk.ChatMessageText("grandchild")},
2917 })
2918 require.NoError(t, err)
2919
2920 // Build a separate, unrelated chain.
2921 unrelated, err := server.CreateChat(ctx, CreateOptions{
2922 OrganizationID: org.ID,
2923 OwnerID: user.ID,
2924 Title: "unrelated-root",

Callers

nothing calls this directly

Calls 10

NewDBFunction · 0.92
ChatMessageTextFunction · 0.92
newInternalTestServerFunction · 0.85
chatdTestContextFunction · 0.85
seedInternalChatDepsFunction · 0.85
isSubagentDescendantFunction · 0.85
CreateChatMethod · 0.65
NewMethod · 0.65
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected