-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwatchlist_test.go
35 lines (29 loc) · 959 Bytes
/
watchlist_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 TestGetWatchlist(t *testing.T) {
client := NewTestClient(func(req *http.Request) *http.Response {
file, _ := os.Open("testdata/mubi-watchlist-sample.json")
return &http.Response{
StatusCode: 200,
Body: ioutil.NopCloser(file),
Header: make(http.Header),
}
})
api := MubiAPI{client}
userId, page, perPage := int64(7995037), 1, 20
watchlist := api.GetWatchlist(userId, page, perPage)
if len(watchlist) != 2 {
t.Errorf("Number of watchlist items was incorrect. Got: %d, expected: %d.", len(watchlist), 2)
}
if watchlist[0].Film.Title != "Fireworks" {
t.Errorf("First film title on watchlist was incorrect. Got: %s, expected: %s.", watchlist[0].Film.Title, "Fireworks")
}
if watchlist[1].Film.Title != "The Intruder" {
t.Errorf("Second film title on watchlist was incorrect. Got: %s, expected: %s.", watchlist[1].Film.Title, "The Intruder")
}
}