(t *testing.T)
| 285 | } |
| 286 | |
| 287 | func Test_renderManualTitlePrompt(t *testing.T) { |
| 288 | t.Parallel() |
| 289 | |
| 290 | longFirstUserText := strings.Repeat("b", 1501) |
| 291 | |
| 292 | tests := []struct { |
| 293 | name string |
| 294 | conversationBlock string |
| 295 | firstUserText string |
| 296 | latestUserMsg string |
| 297 | wantConversationSample bool |
| 298 | wantLatestSection bool |
| 299 | }{ |
| 300 | { |
| 301 | name: "includes conversation sample when provided", |
| 302 | conversationBlock: "[user]: inspect logs\n[assistant]: found flaky test", |
| 303 | firstUserText: "inspect logs", |
| 304 | latestUserMsg: "update quickgen title", |
| 305 | wantConversationSample: true, |
| 306 | wantLatestSection: true, |
| 307 | }, |
| 308 | { |
| 309 | name: "omits optional sections when not needed", |
| 310 | conversationBlock: "", |
| 311 | firstUserText: "inspect logs", |
| 312 | latestUserMsg: "inspect logs", |
| 313 | wantConversationSample: false, |
| 314 | wantLatestSection: false, |
| 315 | }, |
| 316 | { |
| 317 | name: "latest section compares trimmed text", |
| 318 | conversationBlock: "", |
| 319 | firstUserText: "inspect logs", |
| 320 | latestUserMsg: " inspect logs ", |
| 321 | wantConversationSample: false, |
| 322 | wantLatestSection: false, |
| 323 | }, |
| 324 | { |
| 325 | name: "omits latest section when same message truncated", |
| 326 | conversationBlock: "", |
| 327 | firstUserText: longFirstUserText, |
| 328 | latestUserMsg: truncateRunes(longFirstUserText, 1000), |
| 329 | wantConversationSample: false, |
| 330 | wantLatestSection: false, |
| 331 | }, |
| 332 | } |
| 333 | |
| 334 | for _, tt := range tests { |
| 335 | t.Run(tt.name, func(t *testing.T) { |
| 336 | t.Parallel() |
| 337 | |
| 338 | prompt := renderManualTitlePrompt(tt.conversationBlock, tt.firstUserText, tt.latestUserMsg) |
| 339 | |
| 340 | require.Contains(t, prompt, "Primary user objective:") |
| 341 | require.Contains(t, prompt, "Requirements:") |
| 342 | require.Contains(t, prompt, "- Return only the title text in 2-8 words.") |
| 343 | require.Contains(t, prompt, "Do not answer the user or describe the title-writing task") |
| 344 | require.Contains(t, prompt, "stay close to the user's wording") |
nothing calls this directly
no test coverage detected