Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/github/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,12 @@ func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to create comment", resp, body), nil, nil
}

r, err := json.Marshal(createdComment)
minimalResponse := MinimalResponse{
ID: fmt.Sprintf("%d", createdComment.GetID()),
URL: createdComment.GetHTMLURL(),
}

r, err := json.Marshal(minimalResponse)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil
}
Expand Down
11 changes: 5 additions & 6 deletions pkg/github/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,12 @@ func Test_AddIssueComment(t *testing.T) {
// Parse the result and get the text content if no error
textContent := getTextResult(t, result)

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

})
}
Expand Down