Skip to content

Commit c82651f

Browse files
committed
consolidate response structs and remove unneeded message field
1 parent 17c8564 commit c82651f

File tree

6 files changed

+6
-27
lines changed

6 files changed

+6
-27
lines changed

pkg/github/gists.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ func UpdateGist(getClient GetClientFn, t translations.TranslationHelperFunc) (to
259259
minimalResponse := MinimalUpdateResponse{
260260
URL: updatedGist.GetHTMLURL(),
261261
Updated: true,
262-
Message: "Gist updated successfully",
263262
}
264263

265264
r, err := json.Marshal(minimalResponse)

pkg/github/issues.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
873873
}
874874

875875
// Return minimal response with just essential information
876-
minimalResponse := MinimalIssueResponse{
876+
minimalResponse := MinimalResourceResponse{
877877
URL: issue.GetHTMLURL(),
878878
Number: issue.GetNumber(),
879879
State: issue.GetState(),
@@ -1254,7 +1254,6 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
12541254
minimalResponse := MinimalUpdateResponse{
12551255
URL: updatedIssue.GetHTMLURL(),
12561256
Updated: true,
1257-
Message: "Issue updated successfully",
12581257
}
12591258

12601259
r, err := json.Marshal(minimalResponse)

pkg/github/issues_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ func Test_CreateIssue(t *testing.T) {
713713
textContent := getTextResult(t, result)
714714

715715
// Unmarshal and verify the minimal result
716-
var returnedIssue MinimalIssueResponse
716+
var returnedIssue MinimalResourceResponse
717717
err = json.Unmarshal([]byte(textContent.Text), &returnedIssue)
718718
require.NoError(t, err)
719719

pkg/github/minimal_types.go

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,8 @@ type MinimalBranch struct {
107107
Protected bool `json:"protected"`
108108
}
109109

110-
// MinimalCreateResponse represents a minimal response for resource creation operations.
111-
type MinimalCreateResponse struct {
112-
URL string `json:"url"`
113-
ID int64 `json:"id,omitempty"`
114-
Number int `json:"number,omitempty"`
115-
Name string `json:"name,omitempty"`
116-
State string `json:"state,omitempty"`
117-
}
118-
119-
// MinimalPullRequestResponse represents a minimal response for pull request operations.
120-
type MinimalPullRequestResponse struct {
110+
// MinimalResourceResponse represents a minimal response for numbered resource operations (issues, pull requests).
111+
type MinimalResourceResponse struct {
121112
URL string `json:"url"`
122113
Number int `json:"number"`
123114
State string `json:"state"`
@@ -132,19 +123,10 @@ type MinimalRepositoryResponse struct {
132123
FullName string `json:"full_name"`
133124
}
134125

135-
// MinimalIssueResponse represents a minimal response for issue operations.
136-
type MinimalIssueResponse struct {
137-
URL string `json:"url"`
138-
Number int `json:"number"`
139-
State string `json:"state"`
140-
Title string `json:"title,omitempty"`
141-
}
142-
143126
// MinimalUpdateResponse represents a minimal response for update operations.
144127
type MinimalUpdateResponse struct {
145128
URL string `json:"url"`
146129
Updated bool `json:"updated"`
147-
Message string `json:"message,omitempty"`
148130
}
149131

150132
// MinimalGistResponse represents a minimal response for gist operations.

pkg/github/pullrequests.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func CreatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
194194
}
195195

196196
// Return minimal response with just essential information
197-
minimalResponse := MinimalPullRequestResponse{
197+
minimalResponse := MinimalResourceResponse{
198198
URL: pr.GetHTMLURL(),
199199
Number: pr.GetNumber(),
200200
State: pr.GetState(),
@@ -476,7 +476,6 @@ func UpdatePullRequest(getClient GetClientFn, getGQLClient GetGQLClientFn, t tra
476476
minimalResponse := MinimalUpdateResponse{
477477
URL: finalPR.GetHTMLURL(),
478478
Updated: true,
479-
Message: "Pull request updated successfully",
480479
}
481480

482481
r, err := json.Marshal(minimalResponse)

pkg/github/pullrequests_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ func Test_CreatePullRequest(t *testing.T) {
19551955
textContent := getTextResult(t, result)
19561956

19571957
// Unmarshal and verify the minimal result
1958-
var returnedPR MinimalPullRequestResponse
1958+
var returnedPR MinimalResourceResponse
19591959
err = json.Unmarshal([]byte(textContent.Text), &returnedPR)
19601960
require.NoError(t, err)
19611961
assert.Equal(t, tc.expectedPR.GetNumber(), returnedPR.Number)

0 commit comments

Comments
 (0)