-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathcatalog_activities_test.go
127 lines (116 loc) · 3.73 KB
/
catalog_activities_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
116
117
118
119
120
121
122
123
124
125
126
127
package applemusic
import (
"context"
"net/http"
"reflect"
"testing"
)
func TestCatalogService_GetActivity(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/catalog/us/activities/976439514", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
w.WriteHeader(http.StatusOK)
_, _ = w.Write(activitiesJSON)
})
got, _, err := client.Catalog.GetActivity(context.Background(), "us", "976439514", nil)
if err != nil {
t.Errorf("Catalog.GetActivity returned error: %v", err)
}
if want := activities; !reflect.DeepEqual(got, want) {
t.Errorf("Catalog.GetActivity = %+v, want %+v", got, want)
}
}
func TestCatalogService_GetActivitiesByIds(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/catalog/us/activities", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"ids": "976439514,976439503",
})
w.WriteHeader(http.StatusOK)
})
_, _, err := client.Catalog.GetActivitiesByIds(context.Background(), "us", []string{"976439514", "976439503"}, nil)
if err != nil {
t.Errorf("Catalog.GetActivitiesByIds returned error: %v", err)
}
}
var activitiesJSON = []byte(`{
"data": [
{
"id": "976439514",
"type": "activities",
"href": "/v1/catalog/us/activities/976439514",
"attributes": {
"url": "https://itunes.apple.com/us/activity/party/id976439514",
"name": "Party",
"artwork": {
"width": 1080,
"height": 1080,
"url": "https://is1-ssl.mzstatic.com/image/thumb/Features117/v4/99/ed/53/99ed53f5-34b7-6419-b167-cd5a8a3caed2/source/{w}x{h}bb.jpg",
"bgColor": "fff3ab",
"textColor1": "541621",
"textColor2": "3d2d09",
"textColor3": "76423c",
"textColor4": "645529"
},
"editorialNotes": {
"short": "Get it started."
}
},
"relationships": {
"playlists": {
"data": [
{
"id": "pl.2d4d74790f074233b82d07bfae5c219c",
"type": "playlists",
"href": "/v1/catalog/us/playlists/pl.2d4d74790f074233b82d07bfae5c219c"
}
],
"href": "/v1/catalog/us/activities/976439514/playlists",
"next": "/v1/catalog/us/activities/976439514/playlists?offset=10"
}
}
}
]
}`)
var activities = &Activities{
Data: []Activity{
{
Id: "976439514",
Type: "activities",
Href: "/v1/catalog/us/activities/976439514",
Attributes: ActivityAttributes{
URL: "https://itunes.apple.com/us/activity/party/id976439514",
Name: "Party",
Artwork: Artwork{
Width: 1080,
Height: 1080,
URL: "https://is1-ssl.mzstatic.com/image/thumb/Features117/v4/99/ed/53/99ed53f5-34b7-6419-b167-cd5a8a3caed2/source/{w}x{h}bb.jpg",
BgColor: "fff3ab",
TextColor1: "541621",
TextColor2: "3d2d09",
TextColor3: "76423c",
TextColor4: "645529",
},
EditorialNotes: &EditorialNotes{
Short: "Get it started.",
},
},
Relationships: ActivityRelationships{
Playlists: Playlists{
Data: []Playlist{
{
Id: "pl.2d4d74790f074233b82d07bfae5c219c",
Type: "playlists",
Href: "/v1/catalog/us/playlists/pl.2d4d74790f074233b82d07bfae5c219c",
},
},
Href: "/v1/catalog/us/activities/976439514/playlists",
Next: "/v1/catalog/us/activities/976439514/playlists?offset=10",
},
},
},
},
}