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

Commit83c0a74

Browse files
committed
remove pageinfo returns
1 parentd745f5c commit83c0a74

File tree

2 files changed

+17
-67
lines changed

2 files changed

+17
-67
lines changed

‎pkg/github/discussions.go

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,7 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
124124
discussions=append(discussions,di)
125125
}
126126

127-
// Include pagination info in response
128-
response:=map[string]interface{}{
129-
"discussions":discussions,
130-
"pageInfo":map[string]interface{}{
131-
"hasNextPage":query.Repository.Discussions.PageInfo.HasNextPage,
132-
"endCursor":query.Repository.Discussions.PageInfo.EndCursor,
133-
},
134-
}
135-
out,err:=json.Marshal(response)
127+
out,err:=json.Marshal(discussions)
136128
iferr!=nil {
137129
returnnil,fmt.Errorf("failed to marshal discussions: %w",err)
138130
}
@@ -184,15 +176,7 @@ func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelp
184176
discussions=append(discussions,di)
185177
}
186178

187-
// Include pagination info in response
188-
response:=map[string]interface{}{
189-
"discussions":discussions,
190-
"pageInfo":map[string]interface{}{
191-
"hasNextPage":query.Repository.Discussions.PageInfo.HasNextPage,
192-
"endCursor":query.Repository.Discussions.PageInfo.EndCursor,
193-
},
194-
}
195-
out,err:=json.Marshal(response)
179+
out,err:=json.Marshal(discussions)
196180
iferr!=nil {
197181
returnnil,fmt.Errorf("failed to marshal discussions: %w",err)
198182
}
@@ -346,15 +330,7 @@ func GetDiscussionComments(getGQLClient GetGQLClientFn, t translations.Translati
346330
comments=append(comments,&github.IssueComment{Body:github.Ptr(string(c.Body))})
347331
}
348332

349-
result:=map[string]interface{}{
350-
"comments":comments,
351-
"pageInfo":map[string]interface{}{
352-
"hasNextPage":bool(q.Repository.Discussion.Comments.PageInfo.HasNextPage),
353-
"endCursor":string(q.Repository.Discussion.Comments.PageInfo.EndCursor),
354-
},
355-
}
356-
357-
out,err:=json.Marshal(result)
333+
out,err:=json.Marshal(comments)
358334
iferr!=nil {
359335
returnnil,fmt.Errorf("failed to marshal comments: %w",err)
360336
}
@@ -438,15 +414,7 @@ func ListDiscussionCategories(getGQLClient GetGQLClientFn, t translations.Transl
438414
})
439415
}
440416

441-
result:=map[string]interface{}{
442-
"categories":categories,
443-
"pageInfo":map[string]interface{}{
444-
"hasNextPage":bool(q.Repository.DiscussionCategories.PageInfo.HasNextPage),
445-
"endCursor":string(q.Repository.DiscussionCategories.PageInfo.EndCursor),
446-
},
447-
}
448-
449-
out,err:=json.Marshal(result)
417+
out,err:=json.Marshal(categories)
450418
iferr!=nil {
451419
returnnil,fmt.Errorf("failed to marshal discussion categories: %w",err)
452420
}

‎pkg/github/discussions_test.go

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,11 @@ func Test_ListDiscussions(t *testing.T) {
163163
}
164164
require.NoError(t,err)
165165

166-
// Debug: print the actual response
167-
t.Logf("Actual response text: %q",text)
168-
169166
// Parse the structured response with pagination info
170-
varresponsestruct {
171-
Discussions []*github.Discussion`json:"discussions"`
172-
PageInfostruct {
173-
HasNextPagebool`json:"hasNextPage"`
174-
EndCursorstring`json:"endCursor"`
175-
}`json:"pageInfo"`
176-
}
177-
err=json.Unmarshal([]byte(text),&response)
167+
varreturnedDiscussions []*github.Discussion
168+
err=json.Unmarshal([]byte(text),&returnedDiscussions)
178169
require.NoError(t,err)
179170

180-
returnedDiscussions:=response.Discussions
181171
assert.Len(t,returnedDiscussions,tc.expectedCount,"Expected %d discussions, got %d",tc.expectedCount,len(returnedDiscussions))
182172

183173
// Verify that all returned discussions have a category if filtered
@@ -338,18 +328,14 @@ func Test_GetDiscussionComments(t *testing.T) {
338328

339329
textContent:=getTextResult(t,result)
340330

341-
varresponsestruct {
342-
Comments []*github.IssueComment`json:"comments"`
343-
PageInfomap[string]interface{}`json:"pageInfo"`
344-
}
345-
err=json.Unmarshal([]byte(textContent.Text),&response)
331+
varcomments []*github.IssueComment
332+
err=json.Unmarshal([]byte(textContent.Text),&comments)
346333
require.NoError(t,err)
347-
assert.Len(t,response.Comments,2)
334+
assert.Len(t,comments,2)
348335
expectedBodies:= []string{"This is the first comment","This is the second comment"}
349-
fori,comment:=rangeresponse.Comments {
336+
fori,comment:=rangecomments {
350337
assert.Equal(t,expectedBodies[i],*comment.Body)
351338
}
352-
assert.Equal(t,false,response.PageInfo["hasNextPage"])
353339
}
354340

355341
funcTest_ListDiscussionCategories(t*testing.T) {
@@ -394,15 +380,11 @@ func Test_ListDiscussionCategories(t *testing.T) {
394380
require.NoError(t,err)
395381

396382
text:=getTextResult(t,result).Text
397-
varresponsestruct {
398-
Categories []map[string]string`json:"categories"`
399-
PageInfomap[string]interface{}`json:"pageInfo"`
400-
}
401-
require.NoError(t,json.Unmarshal([]byte(text),&response))
402-
assert.Len(t,response.Categories,2)
403-
assert.Equal(t,"123",response.Categories[0]["id"])
404-
assert.Equal(t,"CategoryOne",response.Categories[0]["name"])
405-
assert.Equal(t,"456",response.Categories[1]["id"])
406-
assert.Equal(t,"CategoryTwo",response.Categories[1]["name"])
407-
assert.Equal(t,false,response.PageInfo["hasNextPage"])
383+
varcategories []map[string]string
384+
require.NoError(t,json.Unmarshal([]byte(text),&categories))
385+
assert.Len(t,categories,2)
386+
assert.Equal(t,"123",categories[0]["id"])
387+
assert.Equal(t,"CategoryOne",categories[0]["name"])
388+
assert.Equal(t,"456",categories[1]["id"])
389+
assert.Equal(t,"CategoryTwo",categories[1]["name"])
408390
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp