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

Function assertToolError

internal/cli/tool_test.go:1035–1054  ·  view source on GitHub ↗
(
	t *testing.T,
	stdout string,
	wantCode toolspkg.ErrorCode,
	wantReason toolspkg.ReasonCode,
)

Source from the content-addressed store, hash-verified

1033}
1034
1035func assertToolError(
1036 t *testing.T,
1037 stdout string,
1038 wantCode toolspkg.ErrorCode,
1039 wantReason toolspkg.ReasonCode,
1040) {
1041 t.Helper()
1042
1043 var response ToolErrorResponseRecord
1044 decodeJSONOutput(t, stdout, &response)
1045 if got := response.Error.Code; got != wantCode {
1046 t.Fatalf("error code = %q, want %q; stdout=%s", got, wantCode, stdout)
1047 }
1048 if len(response.Error.ReasonCodes) == 0 || response.Error.ReasonCodes[0] != wantReason {
1049 t.Fatalf("reason codes = %#v, want first %q; stdout=%s", response.Error.ReasonCodes, wantReason, stdout)
1050 }
1051 if len(response.Error.Details) > 0 {
1052 t.Fatalf("details = %#v, want redacted/omitted", response.Error.Details)
1053 }
1054}
1055
1056func sampleToolsResponse() ToolsResponseRecord {
1057 return ToolsResponseRecord{Tools: []ToolRecord{

Calls 1

decodeJSONOutputFunction · 0.85

Tested by

no test coverage detected