From c5520259ca21730bf757bb8f9bf4e4f318e45d7e Mon Sep 17 00:00:00 2001 From: Emil Breiner Date: Mon, 20 May 2024 12:35:50 +0200 Subject: [PATCH] Export pageable interface to ease up mocking The pageable interface was not exported but exposed in the client when retrieving the next page of pageable. This made mocking pretty tough. --- page.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/page.go b/page.go index 1e3ded2..9ef47e6 100644 --- a/page.go +++ b/page.go @@ -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") } @@ -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") }