Add Pagination Options for List Requests #205
|
@ -59,13 +59,13 @@ func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption)
|
|||
return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), jsonHeader, bytes.NewReader(body), status)
|
||||
}
|
||||
|
||||
// ListStatusesOptions options for listing a repository's commit's statuses
|
||||
type ListStatusesOptions struct {
|
||||
6543 marked this conversation as resolved
|
||||
// ListStatusesOption options for listing a repository's commit's statuses
|
||||
type ListStatusesOption struct {
|
||||
ListOptions
|
||||
}
|
||||
|
||||
// ListStatuses returns all statuses for a given Commit
|
||||
func (c *Client) ListStatuses(owner, repo, sha string, opt ListStatusesOptions) ([]*Status, error) {
|
||||
func (c *Client) ListStatuses(owner, repo, sha string, opt ListStatusesOption) ([]*Status, error) {
|
||||
opt.setDefaults()
|
||||
statuses := make([]*Status, 0, opt.PageSize)
|
||||
return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?%s", owner, repo, sha, opt.getURLQuery().Encode()), nil, nil, &statuses)
|
||||
|
|
|
@ -26,13 +26,13 @@ type AccessToken struct {
|
|||
TokenLastEight string `json:"token_last_eight"`
|
||||
}
|
||||
|
||||
// ListAccessTokens options for listing a users's access tokens
|
||||
type ListAccessTokens struct {
|
||||
// ListAccessTokensOptions options for listing a users's access tokens
|
||||
type ListAccessTokensOptions struct {
|
||||
6543 marked this conversation as resolved
6543
commented
rename to ListAccessTokensOptions rename to ListAccessTokensOptions
|
||||
ListOptions
|
||||
}
|
||||
|
||||
// ListAccessTokens lista all the access tokens of user
|
||||
func (c *Client) ListAccessTokens(user, pass string, opt ListAccessTokens) ([]*AccessToken, error) {
|
||||
// ListAccessTokensOptions lists all the access tokens of user
|
||||
func (c *Client) ListAccessTokens(user, pass string, opt ListAccessTokensOptions) ([]*AccessToken, error) {
|
||||
opt.setDefaults()
|
||||
tokens := make([]*AccessToken, 0, opt.PageSize)
|
||||
return tokens, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens?%s", user, opt.getURLQuery().Encode()),
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestUserApp(t *testing.T) {
|
|||
log.Println("== TestUserApp ==")
|
||||
c := newTestClient()
|
||||
|
||||
result, err := c.ListAccessTokens(c.username, c.password, ListAccessTokens{})
|
||||
result, err := c.ListAccessTokens(c.username, c.password, ListAccessTokensOptions{})
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t, result, 1)
|
||||
assert.EqualValues(t, "gitea-admin", result[0].Name)
|
||||
|
@ -37,12 +37,12 @@ func TestUserApp(t *testing.T) {
|
|||
t1, err := c.CreateAccessToken(c.username, c.password, CreateAccessTokenOption{Name: "TestCreateAccessToken"})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, "TestCreateAccessToken", t1.Name)
|
||||
result, _ = c.ListAccessTokens(c.username, c.password, ListAccessTokens{})
|
||||
result, _ = c.ListAccessTokens(c.username, c.password, ListAccessTokensOptions{})
|
||||
assert.Len(t, result, 2)
|
||||
|
||||
err = c.DeleteAccessToken(c.username, c.password, t1.ID)
|
||||
assert.NoError(t, err)
|
||||
result, _ = c.ListAccessTokens(c.username, c.password, ListAccessTokens{})
|
||||
result, _ = c.ListAccessTokens(c.username, c.password, ListAccessTokensOptions{})
|
||||
assert.Len(t, result, 1)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user
dont breake things if necesar!!
rename
ListStatusesOptions
back toListStatusesOption