MCPcopy Create free account
hub / github.com/compozy/agh / TestToolCommandsRenderStructuredErrors

Function TestToolCommandsRenderStructuredErrors

internal/cli/tool_test.go:521–652  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

519}
520
521func 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 },

Callers

nothing calls this directly

Calls 8

toolErrorResponseFunction · 0.85
newToolAPIErrorFunction · 0.85
executeRootCommandFunction · 0.85
newTestDepsFunction · 0.85
assertToolErrorFunction · 0.85
ContainsMethod · 0.80
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected