Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit32b0231

Browse files
Fix more test response parsing - notifications, pull requests, and discussions
Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
1 parentc64cfdc commit32b0231

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

‎pkg/github/discussions_test.go‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,18 @@ func Test_ListDiscussions(t *testing.T) {
442442
require.NoError(t,err)
443443

444444
// Parse the structured response with pagination info
445+
varpaginatedResponsePaginatedResponse
446+
err=json.Unmarshal([]byte(text),&paginatedResponse)
447+
require.NoError(t,err)
448+
449+
// The data field contains the response
450+
dataBytes,err:=json.Marshal(paginatedResponse.Data)
451+
require.NoError(t,err)
445452
varresponsestruct {
446453
Discussions []*github.Discussion`json:"discussions"`
447-
PageInfostruct {
448-
HasNextPagebool`json:"hasNextPage"`
449-
HasPreviousPagebool`json:"hasPreviousPage"`
450-
StartCursorstring`json:"startCursor"`
451-
EndCursorstring`json:"endCursor"`
452-
}`json:"pageInfo"`
453454
TotalCountint`json:"totalCount"`
454455
}
455-
err=json.Unmarshal([]byte(text),&response)
456+
err=json.Unmarshal(dataBytes,&response)
456457
require.NoError(t,err)
457458

458459
assert.Len(t,response.Discussions,tc.expectedCount,"Expected %d discussions, got %d",tc.expectedCount,len(response.Discussions))

‎pkg/github/notifications_test.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,15 @@ func Test_ListNotifications(t *testing.T) {
139139
require.False(t,result.IsError)
140140
textContent:=getTextResult(t,result)
141141
t.Logf("textContent: %s",textContent.Text)
142+
varpaginatedResponsePaginatedResponse
143+
err=json.Unmarshal([]byte(textContent.Text),&paginatedResponse)
144+
require.NoError(t,err)
145+
146+
// The data field contains the notifications
147+
dataBytes,err:=json.Marshal(paginatedResponse.Data)
148+
require.NoError(t,err)
142149
varreturned []*github.Notification
143-
err=json.Unmarshal([]byte(textContent.Text),&returned)
150+
err=json.Unmarshal(dataBytes,&returned)
144151
require.NoError(t,err)
145152
require.NotEmpty(t,returned)
146153
assert.Equal(t,*tc.expectedResult[0].ID,*returned[0].ID)

‎pkg/github/pullrequests_test.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,15 @@ func Test_ListPullRequests(t *testing.T) {
694694
textContent:=getTextResult(t,result)
695695

696696
// Unmarshal and verify the result
697+
varpaginatedResponsePaginatedResponse
698+
err=json.Unmarshal([]byte(textContent.Text),&paginatedResponse)
699+
require.NoError(t,err)
700+
701+
// The data field contains the pull requests
702+
dataBytes,err:=json.Marshal(paginatedResponse.Data)
703+
require.NoError(t,err)
697704
varreturnedPRs []*github.PullRequest
698-
err=json.Unmarshal([]byte(textContent.Text),&returnedPRs)
705+
err=json.Unmarshal(dataBytes,&returnedPRs)
699706
require.NoError(t,err)
700707
assert.Len(t,returnedPRs,2)
701708
assert.Equal(t,*tc.expectedPRs[0].Number,*returnedPRs[0].Number)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp