Skip to content

Commit

Permalink
Export pageable interface to ease up mocking
Browse files Browse the repository at this point in the history
The pageable interface was not exported but exposed in the client when
retrieving the next page of pageable. This made mocking pretty tough.
  • Loading branch information
ebreiner committed May 20, 2024
1 parent 5c1be56 commit c552025
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions page.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ type SimpleShowPage struct {
Shows []FullShow `json:"items"`
}

// pageable is an internal interface for types that support paging
// Pageable is an interface for types that support paging
// by embedding basePage.
type pageable interface{ canPage() }
type Pageable interface{ CanPage() }

func (b *basePage) canPage() {}
func (b *basePage) CanPage() {}

// NextPage fetches the next page of items and writes them into p.
// It returns ErrNoMorePages if p already contains the last page.
func (c *Client) NextPage(ctx context.Context, p pageable) error {
func (c *Client) NextPage(ctx context.Context, p Pageable) error {
if p == nil || reflect.ValueOf(p).IsNil() {
return fmt.Errorf("spotify: p must be a non-nil pointer to a page")
}
Expand All @@ -139,7 +139,7 @@ func (c *Client) NextPage(ctx context.Context, p pageable) error {

// PreviousPage fetches the previous page of items and writes them into p.
// It returns ErrNoMorePages if p already contains the last page.
func (c *Client) PreviousPage(ctx context.Context, p pageable) error {
func (c *Client) PreviousPage(ctx context.Context, p Pageable) error {
if p == nil || reflect.ValueOf(p).IsNil() {
return fmt.Errorf("spotify: p must be a non-nil pointer to a page")
}
Expand Down

0 comments on commit c552025

Please sign in to comment.