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

Function TestService_CreateRun

coderd/x/chatd/chatdebug/service_test.go:97–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func TestService_CreateRun(t *testing.T) {
98 t.Parallel()
99
100 fixture := newFixture(t)
101 rootChat := insertChat(t, fixture.db, fixture.org.ID, fixture.owner.ID, fixture.model.ID)
102 parentChat := insertChat(t, fixture.db, fixture.org.ID, fixture.owner.ID, fixture.model.ID)
103 triggerMsg := insertMessage(t, fixture.db, fixture.chat.ID,
104 fixture.owner.ID, fixture.model.ID, database.ChatMessageRoleUser, "trigger")
105 historyTipMsg := insertMessage(t, fixture.db, fixture.chat.ID,
106 fixture.owner.ID, fixture.model.ID, database.ChatMessageRoleAssistant,
107 "history-tip")
108
109 run, err := fixture.svc.CreateRun(fixture.ctx, chatdebug.CreateRunParams{
110 ChatID: fixture.chat.ID,
111 RootChatID: rootChat.ID,
112 ParentChatID: parentChat.ID,
113 ModelConfigID: fixture.model.ID,
114 TriggerMessageID: triggerMsg.ID,
115 HistoryTipMessageID: historyTipMsg.ID,
116 Kind: chatdebug.KindChatTurn,
117 Status: chatdebug.StatusInProgress,
118 Provider: fixture.model.Provider,
119 Model: fixture.model.Model,
120 Summary: map[string]any{
121 "phase": "create",
122 "count": 1,
123 },
124 })
125 require.NoError(t, err)
126 assertRunMatches(t, run, fixture.chat.ID, rootChat.ID, parentChat.ID,
127 fixture.model.ID, triggerMsg.ID, historyTipMsg.ID,
128 chatdebug.KindChatTurn, chatdebug.StatusInProgress,
129 fixture.model.Provider, fixture.model.Model,
130 `{"count":1,"phase":"create"}`)
131
132 stored, err := fixture.db.GetChatDebugRunByID(fixture.ctx, run.ID)
133 require.NoError(t, err)
134 require.Equal(t, run.ID, stored.ID)
135 require.JSONEq(t, string(run.Summary), string(stored.Summary))
136}
137
138func TestService_CreateRun_TypedNilSummaryUsesDefaultObject(t *testing.T) {
139 t.Parallel()

Callers

nothing calls this directly

Calls 7

newFixtureFunction · 0.85
insertChatFunction · 0.85
insertMessageFunction · 0.85
assertRunMatchesFunction · 0.85
CreateRunMethod · 0.80
GetChatDebugRunByIDMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected