-
Notifications
You must be signed in to change notification settings - Fork 19
/
me_history_test.go
118 lines (111 loc) · 3.26 KB
/
me_history_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
package applemusic
import (
"context"
"net/http"
"reflect"
"testing"
)
func TestMeService_GetHistoryHeavyRotation(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/me/history/heavy-rotation", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
w.WriteHeader(http.StatusOK)
_, _ = w.Write(meHistoryHeavyRotationJSON)
})
got, _, err := client.Me.GetHistoryHeavyRotation(context.Background(), nil)
if err != nil {
t.Errorf("Me.GetHistoryHeavyRotation returned error: %v", err)
}
if want := meHistoryHeavyRotation; !reflect.DeepEqual(got, want) {
t.Errorf("Me.GetHistoryHeavyRotation = %+v, want %+v", got, want)
}
}
var meHistoryHeavyRotationJSON = []byte(`{
"data": [
{
"attributes": {
"artistName": "C\u00e9line Dion",
"artwork": {
"bgColor": "121413",
"height": 600,
"textColor1": "fefefe",
"textColor2": "d5d5d5",
"textColor3": "cfcfcf",
"textColor4": "aeaeae",
"url": "https://example.mzstatic.com/image/thumb/Music/v4/88/23/5b/88235b62-fc2f-e457-c55e-0fe689fb467b/source/{w}x{h}bb.jpg",
"width": 604
},
"copyright": "\u2117 Compilation (P) 2008 Sony Music Entertainment Canada Inc.",
"genreNames": [
"Pop",
"Music",
"Adult Contemporary",
"Soft Rock",
"Vocal",
"Rock"
],
"isComplete": true,
"isSingle": false,
"name": "The Essential Celine Dion",
"playParams": {
"id": "464056948",
"kind": "album"
},
"releaseDate": "2008",
"trackCount": 27,
"url": "https://itunes.apple.com/us/album/the-essential-celine-dion/id464056948"
},
"href": "/v1/catalog/us/albums/464056948",
"id": "464056948",
"type": "albums"
}
],
"href": "/v1/me/history/heavy-rotation?limit=1",
"next": "/v1/me/history/heavy-rotation?offset=1"
}`)
var meHistoryHeavyRotation = &HistoryHeavyRotation{
Data: []Resource{
{
[]byte(`{
"attributes": {
"artistName": "C\u00e9line Dion",
"artwork": {
"bgColor": "121413",
"height": 600,
"textColor1": "fefefe",
"textColor2": "d5d5d5",
"textColor3": "cfcfcf",
"textColor4": "aeaeae",
"url": "https://example.mzstatic.com/image/thumb/Music/v4/88/23/5b/88235b62-fc2f-e457-c55e-0fe689fb467b/source/{w}x{h}bb.jpg",
"width": 604
},
"copyright": "\u2117 Compilation (P) 2008 Sony Music Entertainment Canada Inc.",
"genreNames": [
"Pop",
"Music",
"Adult Contemporary",
"Soft Rock",
"Vocal",
"Rock"
],
"isComplete": true,
"isSingle": false,
"name": "The Essential Celine Dion",
"playParams": {
"id": "464056948",
"kind": "album"
},
"releaseDate": "2008",
"trackCount": 27,
"url": "https://itunes.apple.com/us/album/the-essential-celine-dion/id464056948"
},
"href": "/v1/catalog/us/albums/464056948",
"id": "464056948",
"type": "albums"
}`),
},
},
Href: "/v1/me/history/heavy-rotation?limit=1",
Next: "/v1/me/history/heavy-rotation?offset=1",
}