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

Function Chat

coderd/database/dbgen/dbgen.go:79–109  ·  view source on GitHub ↗
(t testing.TB, db database.Store, seed database.Chat)

Source from the content-addressed store, hash-verified

77}
78
79func Chat(t testing.TB, db database.Store, seed database.Chat) database.Chat {
80 t.Helper()
81
82 var labels pqtype.NullRawMessage
83 if seed.Labels != nil {
84 raw, err := json.Marshal(seed.Labels)
85 require.NoError(t, err, "marshal chat labels")
86 labels = pqtype.NullRawMessage{RawMessage: raw, Valid: true}
87 }
88
89 chat, err := db.InsertChat(genCtx, database.InsertChatParams{
90 OrganizationID: takeFirst(seed.OrganizationID, uuid.New()),
91 OwnerID: takeFirst(seed.OwnerID, uuid.New()),
92 WorkspaceID: seed.WorkspaceID,
93 BuildID: seed.BuildID,
94 AgentID: seed.AgentID,
95 ParentChatID: seed.ParentChatID,
96 RootChatID: seed.RootChatID,
97 LastModelConfigID: takeFirst(seed.LastModelConfigID, uuid.New()),
98 Title: takeFirst(seed.Title, testutil.GetRandomName(t)),
99 Mode: seed.Mode,
100 PlanMode: seed.PlanMode,
101 Status: takeFirst(seed.Status, database.ChatStatusWaiting),
102 MCPServerIDs: seed.MCPServerIDs,
103 Labels: labels,
104 DynamicTools: seed.DynamicTools,
105 ClientType: takeFirst(seed.ClientType, database.ChatClientTypeUi),
106 })
107 require.NoError(t, err, "insert chat")
108 return chat
109}
110
111func ChatMessage(t testing.TB, db database.Store, seed database.ChatMessage) database.ChatMessage {
112 t.Helper()

Callers 15

TestPostChatsFunction · 0.92
TestListChatsFunction · 0.92
TestWatchChatsFunction · 0.92
TestGetChatFunction · 0.92
TestPatchChatFunction · 0.92
TestArchiveChatFunction · 0.92
TestUnarchiveChatFunction · 0.92
TestChatPinOrderFunction · 0.92
TestPostChatMessagesFunction · 0.92

Calls 6

GetRandomNameFunction · 0.92
takeFirstFunction · 0.70
HelperMethod · 0.65
InsertChatMethod · 0.65
NewMethod · 0.65
MarshalMethod · 0.45

Tested by 15

TestPostChatsFunction · 0.74
TestListChatsFunction · 0.74
TestWatchChatsFunction · 0.74
TestGetChatFunction · 0.74
TestPatchChatFunction · 0.74
TestArchiveChatFunction · 0.74
TestUnarchiveChatFunction · 0.74
TestChatPinOrderFunction · 0.74
TestPostChatMessagesFunction · 0.74