diff options
author | 2023-09-12 14:00:35 +0100 | |
---|---|---|
committer | 2023-09-12 14:00:35 +0100 | |
commit | 7293d6029b43db693fd170c0c087394339da0677 (patch) | |
tree | 09063243faf1b178fde35973486e311f66b1ca33 /internal/paging/response_test.go | |
parent | [feature] Allow admins to expire remote public keys; refetch expired keys on ... (diff) | |
download | gotosocial-7293d6029b43db693fd170c0c087394339da0677.tar.xz |
[feature] add paging to account follows, followers and follow requests endpoints (#2186)
Diffstat (limited to 'internal/paging/response_test.go')
-rw-r--r-- | internal/paging/response_test.go | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/internal/paging/response_test.go b/internal/paging/response_test.go index 8eca2a601..b4b7d6058 100644 --- a/internal/paging/response_test.go +++ b/internal/paging/response_test.go @@ -42,9 +42,9 @@ func (suite *PagingSuite) TestPagingStandard() { resp := paging.PackageResponse(params) suite.Equal(make([]interface{}, 10, 10), resp.Items) - suite.Equal(`<https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?max_id=01H11KA1DM2VH3747YDE7FV5HN&limit=10>; rel="next", <https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?min_id=01H11KBBVRRDYYC5KEPME1NP5R&limit=10>; rel="prev"`, resp.LinkHeader) - suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?max_id=01H11KA1DM2VH3747YDE7FV5HN&limit=10`, resp.NextLink) - suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?min_id=01H11KBBVRRDYYC5KEPME1NP5R&limit=10`, resp.PrevLink) + suite.Equal(`<https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&max_id=01H11KA1DM2VH3747YDE7FV5HN>; rel="next", <https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&min_id=01H11KBBVRRDYYC5KEPME1NP5R>; rel="prev"`, resp.LinkHeader) + suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&max_id=01H11KA1DM2VH3747YDE7FV5HN`, resp.NextLink) + suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&min_id=01H11KBBVRRDYYC5KEPME1NP5R`, resp.PrevLink) } func (suite *PagingSuite) TestPagingNoLimit() { @@ -77,9 +77,9 @@ func (suite *PagingSuite) TestPagingNoNextID() { resp := paging.PackageResponse(params) suite.Equal(make([]interface{}, 10, 10), resp.Items) - suite.Equal(`<https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?min_id=01H11KBBVRRDYYC5KEPME1NP5R&limit=10>; rel="prev"`, resp.LinkHeader) + suite.Equal(`<https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&min_id=01H11KBBVRRDYYC5KEPME1NP5R>; rel="prev"`, resp.LinkHeader) suite.Equal(``, resp.NextLink) - suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?min_id=01H11KBBVRRDYYC5KEPME1NP5R&limit=10`, resp.PrevLink) + suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&min_id=01H11KBBVRRDYYC5KEPME1NP5R`, resp.PrevLink) } func (suite *PagingSuite) TestPagingNoPrevID() { @@ -94,27 +94,11 @@ func (suite *PagingSuite) TestPagingNoPrevID() { resp := paging.PackageResponse(params) suite.Equal(make([]interface{}, 10, 10), resp.Items) - suite.Equal(`<https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?max_id=01H11KA1DM2VH3747YDE7FV5HN&limit=10>; rel="next"`, resp.LinkHeader) - suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?max_id=01H11KA1DM2VH3747YDE7FV5HN&limit=10`, resp.NextLink) + suite.Equal(`<https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&max_id=01H11KA1DM2VH3747YDE7FV5HN>; rel="next"`, resp.LinkHeader) + suite.Equal(`https://example.org/api/v1/accounts/01H11KA68PM4NNYJEG0FJQ90R3/statuses?limit=10&max_id=01H11KA1DM2VH3747YDE7FV5HN`, resp.NextLink) suite.Equal(``, resp.PrevLink) } -func (suite *PagingSuite) TestPagingNoItems() { - config.SetHost("example.org") - - params := paging.ResponseParams{ - Next: nextPage("01H11KA1DM2VH3747YDE7FV5HN", 10), - Prev: prevPage("01H11KBBVRRDYYC5KEPME1NP5R", 10), - } - - resp := paging.PackageResponse(params) - - suite.Empty(resp.Items) - suite.Empty(resp.LinkHeader) - suite.Empty(resp.NextLink) - suite.Empty(resp.PrevLink) -} - func TestPagingSuite(t *testing.T) { suite.Run(t, &PagingSuite{}) } @@ -128,7 +112,7 @@ func nextPage(id string, limit int) *paging.Page { func prevPage(id string, limit int) *paging.Page { return &paging.Page{ - Min: paging.MinID(id, ""), + Min: paging.MinID(id), Limit: limit, } } |