Skip to content

Commit 31ed16b

Browse files
committed
Return page parameters
1 parent 066770a commit 31ed16b

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

pkg/github/repositories.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2293,7 +2293,15 @@ func ListRepositoryCollaborators(t translations.TranslationHelperFunc) inventory
22932293
})
22942294
}
22952295

2296-
return MarshalledTextResult(result), nil, nil
2296+
response := map[string]any{
2297+
"items": result,
2298+
"nextPage": resp.NextPage,
2299+
"prevPage": resp.PrevPage,
2300+
"firstPage": resp.FirstPage,
2301+
"lastPage": resp.LastPage,
2302+
}
2303+
2304+
return MarshalledTextResult(response), nil, nil
22972305
},
22982306
)
22992307
}

pkg/github/repositories_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,15 +4488,22 @@ func Test_ListRepositoryCollaborators(t *testing.T) {
44884488
textContent := getTextResult(t, result)
44894489
require.NotEmpty(t, textContent.Text)
44904490

4491-
var collaborators []MinimalCollaborator
4492-
err = json.Unmarshal([]byte(textContent.Text), &collaborators)
4491+
var response struct {
4492+
Items []MinimalCollaborator `json:"items"`
4493+
NextPage int `json:"nextPage"`
4494+
PrevPage int `json:"prevPage"`
4495+
FirstPage int `json:"firstPage"`
4496+
LastPage int `json:"lastPage"`
4497+
}
4498+
err = json.Unmarshal([]byte(textContent.Text), &response)
44934499
require.NoError(t, err)
44944500

44954501
if tt.name == "empty collaborators returns empty array" {
4496-
assert.Empty(t, collaborators)
4502+
assert.Empty(t, response.Items)
44974503
return
44984504
}
44994505

4506+
collaborators := response.Items
45004507
assert.Len(t, collaborators, 2)
45014508
assert.Equal(t, "user1", collaborators[0].Login)
45024509
assert.Equal(t, int64(101), collaborators[0].ID)

0 commit comments

Comments
 (0)