TestPrepareUserMessage_AgentSwitching tests that PrepareUserMessage correctly handles agent-switching commands and returns empty messages on switch failures.
(t *testing.T)
| 320 | // TestPrepareUserMessage_AgentSwitching tests that PrepareUserMessage correctly |
| 321 | // handles agent-switching commands and returns empty messages on switch failures. |
| 322 | func TestPrepareUserMessage_AgentSwitching(t *testing.T) { |
| 323 | t.Parallel() |
| 324 | |
| 325 | tests := []struct { |
| 326 | name string |
| 327 | userInput string |
| 328 | commandAgent string |
| 329 | setAgentErr error |
| 330 | expectedContent string |
| 331 | expectedAttach string |
| 332 | expectAgentSwitch bool |
| 333 | expectNilMessage bool |
| 334 | expectError bool |
| 335 | }{ |
| 336 | { |
| 337 | name: "agent switch succeeds with trailing args", |
| 338 | userInput: "/plan design a login flow", |
| 339 | commandAgent: "planner", |
| 340 | setAgentErr: nil, |
| 341 | expectedContent: "design a login flow", |
| 342 | expectedAttach: "", |
| 343 | expectAgentSwitch: true, |
| 344 | }, |
| 345 | { |
| 346 | name: "agent switch succeeds without trailing args", |
| 347 | userInput: "/plan", |
| 348 | commandAgent: "planner", |
| 349 | setAgentErr: nil, |
| 350 | expectedContent: "", |
| 351 | expectedAttach: "", |
| 352 | expectAgentSwitch: true, |
| 353 | expectNilMessage: true, |
| 354 | }, |
| 355 | { |
| 356 | name: "agent switch fails - returns error", |
| 357 | userInput: "/plan design a login flow", |
| 358 | commandAgent: "planner", |
| 359 | setAgentErr: errors.New("agent not found"), |
| 360 | expectedContent: "", |
| 361 | expectedAttach: "", |
| 362 | expectAgentSwitch: true, |
| 363 | expectError: true, |
| 364 | }, |
| 365 | { |
| 366 | name: "non-agent command - no switch", |
| 367 | userInput: "/test regular command", |
| 368 | commandAgent: "", |
| 369 | setAgentErr: nil, |
| 370 | expectedContent: "This is the test instruction regular command", |
| 371 | expectedAttach: "", |
| 372 | expectAgentSwitch: false, |
| 373 | }, |
| 374 | } |
| 375 | |
| 376 | for _, tt := range tests { |
| 377 | t.Run(tt.name, func(t *testing.T) { |
| 378 | t.Parallel() |
| 379 |
nothing calls this directly
no test coverage detected