-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfollowers_test.go
35 lines (29 loc) · 970 Bytes
/
followers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package mubi
import (
"io/ioutil"
"net/http"
"os"
"testing"
)
func TestGetFollowers(t *testing.T) {
client := NewTestClient(func(req *http.Request) *http.Response {
file, _ := os.Open("testdata/mubi-followers-sample.json")
return &http.Response{
StatusCode: 200,
Body: ioutil.NopCloser(file),
Header: make(http.Header),
}
})
api := MubiAPI{client}
userId, page, perPage := int64(6164674), 1, 20
followers := api.GetFollowers(userId, page, perPage)
if len(followers) != 20 {
t.Errorf("Number of follower items was incorrect. Got: %d, expected: %d.", len(followers), 20)
}
if followers[0].Follower.Name != "Ryuu Baron" {
t.Errorf("Name of first followed user was incorrect. Got: %s, expected: %s.", followers[0].Follower.Name, "Ryuu Baron")
}
if followers[1].Follower.Name != "Filip Klokan" {
t.Errorf("Name of second followed user was incorrect. Got: %s, expected: %s.", followers[1].Follower.Name, "Filip Klokan")
}
}