Skip to content

Commit 52dcea0

Browse files
Support limit for following (#38)
* Support limit for following * Add tests for limit
1 parent 2f8ab36 commit 52dcea0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

controllers/me_following_users_controller.go

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package controllers
22

33
import (
4+
"strconv"
5+
46
"github.com/BrandonRomano/wrecker"
57
"github.com/carrot/go-pinterest/models"
68
)
@@ -22,6 +24,7 @@ func newMeFollowingUsersController(wc *wrecker.Wrecker) *MeFollowingUsersControl
2224
// parameters for the Fetch method
2325
type FollowingUsersControllerFetchOptionals struct {
2426
Cursor string
27+
Limit int
2528
}
2629

2730
// Fetch loads the users that the authorized user follows
@@ -36,6 +39,9 @@ func (c *MeFollowingUsersController) Fetch(optionals *FollowingUsersControllerFe
3639
if optionals.Cursor != "" {
3740
request.URLParam("cursor", optionals.Cursor)
3841
}
42+
if optionals.Limit != 0 {
43+
request.URLParam("limit", strconv.Itoa(optionals.Limit))
44+
}
3945
httpResp, err := request.Execute()
4046

4147
// Check Error

pinterest_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1083,13 +1083,14 @@ func (suite *ClientTestSuite) TestSuccessfulMeFollowingUsersFetch() {
10831083
assert.Equal(suite.T(), len(*users), 25)
10841084

10851085
// Load second page
1086-
suite.client.Me.Following.Users.Fetch(
1086+
users, _, err = suite.client.Me.Following.Users.Fetch(
10871087
&controllers.FollowingUsersControllerFetchOptionals{
10881088
Cursor: page.Cursor,
1089+
Limit: 3,
10891090
},
10901091
)
10911092
assert.Equal(suite.T(), nil, err)
1092-
assert.True(suite.T(), len(*users) > 0)
1093+
assert.True(suite.T(), len(*users) == 3)
10931094
}
10941095

10951096
// TestTimeoutMeFollowingUsersFetch tests that an error is appropriately thrown

0 commit comments

Comments
 (0)