-
Notifications
You must be signed in to change notification settings - Fork 19
/
catalog_music_videos_test.go
139 lines (128 loc) · 3.57 KB
/
catalog_music_videos_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
128
129
130
131
132
133
134
135
136
137
138
139
package applemusic
import (
"context"
"net/http"
"reflect"
"testing"
)
func TestCatalogService_GetMusicVideo(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/catalog/us/music-videos/639032181", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
w.WriteHeader(http.StatusOK)
_, _ = w.Write(musicVideosJSON)
})
got, _, err := client.Catalog.GetMusicVideo(context.Background(), "us", "639032181", nil)
if err != nil {
t.Errorf("Catalog.GetMusicVideo returned error: %v", err)
}
if want := musicVideos; !reflect.DeepEqual(got, want) {
t.Errorf("Catalog.GetMusicVideo = %+v, want %+v", got, want)
}
}
func TestCatalogService_GetMusicVideosByIds(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/catalog/us/music-videos", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"ids": "639032181,870852283",
})
w.WriteHeader(http.StatusOK)
})
_, _, err := client.Catalog.GetMusicVideosByIds(context.Background(), "us", []string{"639032181", "870852283"}, nil)
if err != nil {
t.Errorf("Catalog.GetMusicVideosByIds returned error: %v", err)
}
}
var musicVideosJSON = []byte(`{
"data": [
{
"id": "639032181",
"type": "music-videos",
"href": "/v1/catalog/us/music-videos/639032181",
"attributes": {
"url": "https://itunes.apple.com/us/music-video/thatpower-feat-justin-bieber/id639032181",
"name": "#thatPOWER (feat. Justin Bieber)",
"genreNames": [
"Pop"
],
"isrc": "USUV71300701",
"artistName": "will.i.am",
"releaseDate": "2013-01-01",
"artwork": {
"width": 640,
"height": 288,
"url": "https://is1-ssl.mzstatic.com/image/thumb/Video/v4/ef/81/a8/ef81a86e-7144-ba9e-2de0-7b5fe6d2acfd/source/{w}x{h}bb.jpg"
},
"playParams": {
"id": "639032181",
"kind": "musicVideo"
},
"durationInMillis": 292833
},
"relationships": {
"albums": {
"data": [],
"href": "/v1/catalog/us/music-videos/639032181/albums"
},
"artists": {
"data": [
{
"id": "3495273",
"type": "artists",
"href": "/v1/catalog/us/artists/3495273"
}
],
"href": "/v1/catalog/us/music-videos/639032181/artists"
}
}
}
]
}`)
var musicVideos = &MusicVideos{
Data: []MusicVideo{
{
Id: "639032181",
Type: "music-videos",
Href: "/v1/catalog/us/music-videos/639032181",
Attributes: MusicVideoAttributes{
URL: "https://itunes.apple.com/us/music-video/thatpower-feat-justin-bieber/id639032181",
Name: "#thatPOWER (feat. Justin Bieber)",
GenreNames: []string{
"Pop",
},
ISRC: "USUV71300701",
ArtistName: "will.i.am",
ReleaseDate: "2013-01-01",
Artwork: Artwork{
Width: 640,
Height: 288,
URL: "https://is1-ssl.mzstatic.com/image/thumb/Video/v4/ef/81/a8/ef81a86e-7144-ba9e-2de0-7b5fe6d2acfd/source/{w}x{h}bb.jpg",
},
PlayParams: &PlayParameters{
Id: "639032181",
Kind: "musicVideo",
},
DurationInMillis: 292833,
},
Relationships: MusicVideoRelationships{
Albums: Albums{
Data: []Album{},
Href: "/v1/catalog/us/music-videos/639032181/albums",
},
Artists: Artists{
Data: []Artist{
{
Id: "3495273",
Type: "artists",
Href: "/v1/catalog/us/artists/3495273",
},
},
Href: "/v1/catalog/us/music-videos/639032181/artists",
},
},
},
},
}