Skip to content

Commit 98b5647

Browse files
Clean up code
1 parent 3d71005 commit 98b5647

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

pkg/github/issue_fields.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io"
87
"net/http"
98

10-
ghErrors "github.com/github/github-mcp-server/pkg/errors"
119
"github.com/github/github-mcp-server/pkg/inventory"
1210
"github.com/github/github-mcp-server/pkg/scopes"
1311
"github.com/github/github-mcp-server/pkg/translations"
@@ -87,15 +85,6 @@ func ListOrgIssueFields(t translations.TranslationHelperFunc) inventory.ServerTo
8785
}
8886
return utils.NewToolResultErrorFromErr("failed to list issue fields", err), nil, nil
8987
}
90-
defer func() { _ = resp.Body.Close() }()
91-
92-
if resp.StatusCode != http.StatusOK {
93-
body, readErr := io.ReadAll(resp.Body)
94-
if readErr != nil {
95-
return utils.NewToolResultErrorFromErr("failed to read response body", readErr), nil, nil
96-
}
97-
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to list issue fields", resp, body), nil, nil
98-
}
9988

10089
r, err := json.Marshal(fields)
10190
if err != nil {

pkg/github/issue_fields_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,28 @@ func Test_ListOrgIssueFields(t *testing.T) {
9292
expectError: false,
9393
expectedErrMsg: "missing required parameter: org",
9494
},
95+
{
96+
name: "forbidden returns error",
97+
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
98+
"GET /orgs/testorg/issue-fields": mockResponse(t, http.StatusForbidden, `{"message": "Forbidden"}`),
99+
}),
100+
requestArgs: map[string]any{
101+
"org": "testorg",
102+
},
103+
expectError: false,
104+
expectedErrMsg: "failed to list issue fields",
105+
},
106+
{
107+
name: "internal server error returns error",
108+
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
109+
"GET /orgs/testorg/issue-fields": mockResponse(t, http.StatusInternalServerError, `{"message": "Internal Server Error"}`),
110+
}),
111+
requestArgs: map[string]any{
112+
"org": "testorg",
113+
},
114+
expectError: false,
115+
expectedErrMsg: "failed to list issue fields",
116+
},
95117
}
96118

97119
for _, tc := range tests {

0 commit comments

Comments
 (0)