Skip to content

Commit ed5c376

Browse files
Fix GraphQL test response structures and remaining pagination params
Co-authored-by: SamMorrowDrums <[email protected]>
1 parent 252081f commit ed5c376

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pkg/github/issues_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,17 +1009,18 @@ func Test_ListIssues(t *testing.T) {
10091009
require.NoError(t, err)
10101010

10111011
// Parse the structured response with pagination info
1012+
var paginatedResponse PaginatedResponse
1013+
err = json.Unmarshal([]byte(text), &paginatedResponse)
1014+
require.NoError(t, err)
1015+
1016+
// The data field contains the response
1017+
dataBytes, err := json.Marshal(paginatedResponse.Data)
1018+
require.NoError(t, err)
10121019
var response struct {
10131020
Issues []*github.Issue `json:"issues"`
1014-
PageInfo struct {
1015-
HasNextPage bool `json:"hasNextPage"`
1016-
HasPreviousPage bool `json:"hasPreviousPage"`
1017-
StartCursor string `json:"startCursor"`
1018-
EndCursor string `json:"endCursor"`
1019-
} `json:"pageInfo"`
10201021
TotalCount int `json:"totalCount"`
10211022
}
1022-
err = json.Unmarshal([]byte(text), &response)
1023+
err = json.Unmarshal(dataBytes, &response)
10231024
require.NoError(t, err)
10241025

10251026
assert.Len(t, response.Issues, tc.expectedCount, "Expected %d issues, got %d", tc.expectedCount, len(response.Issues))
@@ -1651,7 +1652,7 @@ func Test_GetIssueComments(t *testing.T) {
16511652
mock.GetReposIssuesCommentsByOwnerByRepoByIssueNumber,
16521653
expectQueryParams(t, map[string]string{
16531654
"page": "2",
1654-
"per_page": "10",
1655+
"per_page": "11",
16551656
}).andThen(
16561657
mockResponse(t, http.StatusOK, mockComments),
16571658
),
@@ -1662,8 +1663,7 @@ func Test_GetIssueComments(t *testing.T) {
16621663
"owner": "owner",
16631664
"repo": "repo",
16641665
"issue_number": float64(42),
1665-
"page": float64(2),
1666-
"perPage": float64(10),
1666+
"cursor": "page=2;perPage=10",
16671667
},
16681668
expectError: false,
16691669
expectedComments: mockComments,

0 commit comments

Comments
 (0)