-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshows_test.go
115 lines (96 loc) · 2.58 KB
/
shows_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package spotify
import (
"net/http"
"testing"
)
func TestGetShow(t *testing.T) {
client, server := testClientFile(http.StatusOK, "get_a_show.txt")
defer server.Close()
res, err := client.GetShow("38bS44xjbVVZ3No3ByF1dJ", "ES")
if err != nil {
t.Fatal(err)
}
if res == nil {
t.Error("Expected response")
} else {
if res.ID != "38bS44xjbVVZ3No3ByF1dJ" {
t.Errorf("Expected %s, got %s", "38bS44xjbVVZ3No3ByF1dJ", res.ID)
}
}
}
func TestGetSeveralShows(t *testing.T) {
client, server := testClientFile(http.StatusOK, "get_several_shows.txt")
defer server.Close()
res, err := client.GetSeveralShows([]string{"5CfCWKI5pZ28U0uOzXkDHe", "5as3aKmN2k11yfDDDSrvaZ"}, "ES")
if err != nil {
t.Fatal(err)
}
if res != nil {
if len(res.Shows) != 2 {
t.Errorf("Expected %d, got %d", 2, len(res.Shows))
}
} else {
t.Error("Expected response")
}
}
func TestGetShowEpisodes(t *testing.T) {
client, server := testClientFile(http.StatusOK, "get_show_episodes.txt")
defer server.Close()
res, err := client.GetShowEpisodes("38bS44xjbVVZ3No3ByF1dJ", &GetShowEpisodesParams{
Market: MarketSpain,
Limit: 10,
Offset: 0,
})
if err != nil {
t.Fatal(err)
}
if res != nil {
if len(res.Items) != 10 {
t.Errorf("Expected %d, got %d", 10, len(res.Items))
}
} else {
t.Error("Expected response")
}
}
func TestGetUsersSavedShows(t *testing.T) {
client, server := testClientFile(http.StatusOK, "get_users_saved_shows.txt")
defer server.Close()
res, err := client.GetUsersSavedShows(&GetUsersSavedShowsParams{
Limit: 20,
Offset: 0,
})
if err != nil {
t.Fatal(err)
}
if res != nil {
if len(res.Items) != 2 {
t.Errorf("Expected %d, got %d", 2, len(res.Items))
}
} else {
t.Error("Expected response")
}
}
func TestSaveShowsForCurrentUser(t *testing.T) {
client, server := testClientFile(http.StatusOK, "save_shows_for_current_user.txt")
defer server.Close()
err := client.SaveShowsForCurrentUser([]string{"5CfCWKI5pZ28U0uOzXkDHe", "5as3aKmN2k11yfDDDSrvaZ"})
if err != nil {
t.Fatal(err)
}
}
func TestRemoveUsersSavedShows(t *testing.T) {
client, server := testClientFile(http.StatusOK, "remove_users_saved_shows.txt")
defer server.Close()
err := client.RemoveUsersSavedShows([]string{"5CfCWKI5pZ28U0uOzXkDHe", "5as3aKmN2k11yfDDDSrvaZ"}, "ES")
if err != nil {
t.Fatal(err)
}
}
func TestCheckUsersSavedShows(t *testing.T) {
client, server := testClientFile(http.StatusOK, "check_users_saved_shows.txt")
defer server.Close()
err := client.CheckUsersSavedShows([]string{"5CfCWKI5pZ28U0uOzXkDHe", "5as3aKmN2k11yfDDDSrvaZ"})
if err != nil {
t.Fatal(err)
}
}