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

Function TestProposeChatTitle_DebugRun

coderd/x/chatd/chatd_test.go:5924–6051  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5922}
5923
5924func TestProposeChatTitle_DebugRun(t *testing.T) {
5925 t.Parallel()
5926
5927 wantTitle := "Debug proposal title"
5928 tests := []struct {
5929 name string
5930 alwaysEnableDebugLogs bool
5931 response func() chattest.OpenAIResponse
5932 wantErr bool
5933 wantTitle string
5934 wantTitleGenerationRuns int
5935 wantDebugStatus codersdk.ChatDebugStatus
5936 }{
5937 {
5938 name: "Enabled",
5939 alwaysEnableDebugLogs: true,
5940 response: func() chattest.OpenAIResponse {
5941 return chattest.OpenAINonStreamingResponse(
5942 "{\"title\":\"" + wantTitle + "\"}",
5943 )
5944 },
5945 wantTitle: wantTitle,
5946 wantTitleGenerationRuns: 1,
5947 wantDebugStatus: codersdk.ChatDebugStatusCompleted,
5948 },
5949 {
5950 name: "Disabled",
5951 alwaysEnableDebugLogs: false,
5952 response: func() chattest.OpenAIResponse {
5953 return chattest.OpenAINonStreamingResponse(
5954 "{\"title\":\"" + wantTitle + "\"}",
5955 )
5956 },
5957 wantTitle: wantTitle,
5958 },
5959 {
5960 name: "GenerationErrorFinalizesDebugRun",
5961 alwaysEnableDebugLogs: true,
5962 response: func() chattest.OpenAIResponse {
5963 return chattest.OpenAINonStreamingResponse("not json")
5964 },
5965 wantErr: true,
5966 wantTitleGenerationRuns: 1,
5967 wantDebugStatus: codersdk.ChatDebugStatusError,
5968 },
5969 }
5970
5971 for _, tt := range tests {
5972 t.Run(tt.name, func(t *testing.T) {
5973 t.Parallel()
5974
5975 ctx := testutil.Context(t, testutil.WaitLong)
5976 db, ps, rawDB := dbtestutil.NewDBWithSQLDB(t)
5977 openAIURL := chattest.NewOpenAI(t, func(req *chattest.OpenAIRequest) chattest.OpenAIResponse {
5978 require.False(t, req.Stream)
5979 return tt.response()
5980 })
5981 user, org, model := seedChatDependenciesWithProvider(

Callers

nothing calls this directly

Calls 15

ContextFunction · 0.92
NewDBWithSQLDBFunction · 0.92
NewOpenAIFunction · 0.92
NewFunction · 0.92
ChatFunction · 0.92
insertUserTextMessageFunction · 0.85
QueryRowContextMethod · 0.80
RunMethod · 0.65
NewMethod · 0.65
CleanupMethod · 0.65

Tested by

no test coverage detected