-
Notifications
You must be signed in to change notification settings - Fork 19
/
catalog_stations_test.go
113 lines (102 loc) · 2.91 KB
/
catalog_stations_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
package applemusic
import (
"context"
"net/http"
"reflect"
"testing"
)
func TestCatalogService_GetStation(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/catalog/us/stations/ra.985484166", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
w.WriteHeader(http.StatusOK)
_, _ = w.Write(stationsJSON)
})
got, _, err := client.Catalog.GetStation(context.Background(), "us", "ra.985484166", nil)
if err != nil {
t.Errorf("Catalog.GetStation returned error: %v", err)
}
if want := stations; !reflect.DeepEqual(got, want) {
t.Errorf("Catalog.GetStation = %+v, want %+v", got, want)
}
}
func TestCatalogService_GetStationsByIds(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1/catalog/us/stations", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"ids": "ra.985484166,ra.1128062616",
})
w.WriteHeader(http.StatusOK)
})
_, _, err := client.Catalog.GetStationsByIds(context.Background(), "us", []string{"ra.985484166", "ra.1128062616"}, nil)
if err != nil {
t.Errorf("Catalog.GetStationsByIds returned error: %v", err)
}
}
var stationsJSON = []byte(`{
"data": [
{
"id": "ra.985484166",
"type": "stations",
"href": "/v1/catalog/us/stations/ra.985484166",
"attributes": {
"url": "https://itunes.apple.com/us/station/alternative/idra.985484166",
"name": "Alternative",
"artwork": {
"width": 4320,
"height": 1080,
"url": "https://is3-ssl.mzstatic.com/image/thumb/Features111/v4/9a/e0/94/9ae0941a-721e-0b00-527c-e57723dad20f/source/{w}x{h}bb.jpg",
"bgColor": "ede9d4",
"textColor1": "140c04",
"textColor2": "121210",
"textColor3": "3f382d",
"textColor4": "3d3d37"
},
"playParams": {
"id": "ra.985484166",
"kind": "radioStation"
},
"editorialNotes": {
"name": "Alternative",
"short": "The margins to mainstream."
},
"isLive": false
}
}
]
}`)
var stations = &Stations{
Data: []Station{
{
Id: "ra.985484166",
Type: "stations",
Href: "/v1/catalog/us/stations/ra.985484166",
Attributes: StationAttributes{
URL: "https://itunes.apple.com/us/station/alternative/idra.985484166",
Name: "Alternative",
Artwork: Artwork{
Width: 4320,
Height: 1080,
URL: "https://is3-ssl.mzstatic.com/image/thumb/Features111/v4/9a/e0/94/9ae0941a-721e-0b00-527c-e57723dad20f/source/{w}x{h}bb.jpg",
BgColor: "ede9d4",
TextColor1: "140c04",
TextColor2: "121210",
TextColor3: "3f382d",
TextColor4: "3d3d37",
},
PlayParams: PlayParameters{
Id: "ra.985484166",
Kind: "radioStation",
},
EditorialNotes: &EditorialNotes{
Name: "Alternative",
Short: "The margins to mainstream.",
},
IsLive: false,
},
},
},
}