(t *testing.T)
| 5922 | } |
| 5923 | |
| 5924 | func 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( |
nothing calls this directly
no test coverage detected