(t *testing.T)
| 519 | } |
| 520 | |
| 521 | func TestToolCommandsRenderStructuredErrors(t *testing.T) { |
| 522 | t.Parallel() |
| 523 | |
| 524 | testCases := []struct { |
| 525 | name string |
| 526 | statusCode int |
| 527 | payload ToolErrorResponseRecord |
| 528 | wantCode toolspkg.ErrorCode |
| 529 | wantReason toolspkg.ReasonCode |
| 530 | }{ |
| 531 | { |
| 532 | name: "Should render denied errors", |
| 533 | statusCode: 403, |
| 534 | payload: toolErrorResponse( |
| 535 | toolspkg.ErrorCodeDenied, |
| 536 | toolspkg.ReasonPolicyDenied, |
| 537 | "tool denied token=super-secret", |
| 538 | "policy", |
| 539 | ), |
| 540 | wantCode: toolspkg.ErrorCodeDenied, |
| 541 | wantReason: toolspkg.ReasonPolicyDenied, |
| 542 | }, |
| 543 | { |
| 544 | name: "Should render unavailable errors", |
| 545 | statusCode: 422, |
| 546 | payload: toolErrorResponse( |
| 547 | toolspkg.ErrorCodeUnavailable, |
| 548 | toolspkg.ReasonBackendUnhealthy, |
| 549 | "tool unavailable", |
| 550 | "availability", |
| 551 | ), |
| 552 | wantCode: toolspkg.ErrorCodeUnavailable, |
| 553 | wantReason: toolspkg.ReasonBackendUnhealthy, |
| 554 | }, |
| 555 | { |
| 556 | name: "Should render auth required diagnostics", |
| 557 | statusCode: 422, |
| 558 | payload: toolErrorResponse( |
| 559 | toolspkg.ErrorCodeUnavailable, |
| 560 | toolspkg.ReasonMCPAuthRequired, |
| 561 | "mcp login required", |
| 562 | "auth", |
| 563 | ), |
| 564 | wantCode: toolspkg.ErrorCodeUnavailable, |
| 565 | wantReason: toolspkg.ReasonMCPAuthRequired, |
| 566 | }, |
| 567 | { |
| 568 | name: "Should render conflicted errors", |
| 569 | statusCode: 409, |
| 570 | payload: toolErrorResponse( |
| 571 | toolspkg.ErrorCodeConflict, |
| 572 | toolspkg.ReasonConflictedID, |
| 573 | "tool id conflict", |
| 574 | "registry", |
| 575 | ), |
| 576 | wantCode: toolspkg.ErrorCodeConflict, |
| 577 | wantReason: toolspkg.ReasonConflictedID, |
| 578 | }, |
nothing calls this directly
no test coverage detected