Skip to content

Commit 7d71493

Browse files
committed
reduce context for add_issue_comments using minimal types
1 parent 16ff74a commit 7d71493

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

pkg/github/issues.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,12 @@ func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool
688688
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to create comment", resp, body), nil, nil
689689
}
690690

691-
r, err := json.Marshal(createdComment)
691+
minimalResponse := MinimalResponse{
692+
ID: fmt.Sprintf("%d", createdComment.GetID()),
693+
URL: createdComment.GetHTMLURL(),
694+
}
695+
696+
r, err := json.Marshal(minimalResponse)
692697
if err != nil {
693698
return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil
694699
}

pkg/github/issues_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,12 @@ func Test_AddIssueComment(t *testing.T) {
458458
// Parse the result and get the text content if no error
459459
textContent := getTextResult(t, result)
460460

461-
// Unmarshal and verify the result
462-
var returnedComment github.IssueComment
463-
err = json.Unmarshal([]byte(textContent.Text), &returnedComment)
461+
// Unmarshal and verify the result contains minimal response
462+
var minimalResponse MinimalResponse
463+
err = json.Unmarshal([]byte(textContent.Text), &minimalResponse)
464464
require.NoError(t, err)
465-
assert.Equal(t, *tc.expectedComment.ID, *returnedComment.ID)
466-
assert.Equal(t, *tc.expectedComment.Body, *returnedComment.Body)
467-
assert.Equal(t, *tc.expectedComment.User.Login, *returnedComment.User.Login)
465+
assert.Equal(t, fmt.Sprintf("%d", tc.expectedComment.GetID()), minimalResponse.ID)
466+
assert.Equal(t, tc.expectedComment.GetHTMLURL(), minimalResponse.URL)
468467

469468
})
470469
}

0 commit comments

Comments
 (0)