This repository has been archived by the owner on May 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmediaSearchMediaCollection_test.go
106 lines (86 loc) · 20.8 KB
/
mediaSearchMediaCollection_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
package casatunes
import (
"testing"
"net/http"
"reflect"
)
type mediaSearchMCHandler struct {
response string
status int
}
func newMediaSearchMCHandler() *mediaSearchMCHandler {
return &mediaSearchMCHandler{
response: `{"Flags":532504,"ID":"sr:6721d1e8-5697-49f0-84c2-b20f72bb2c04","Title":"Search Results for: baloons","DisplayInfo":["Search Results for: baloons"],"ArtworkRatio":0,"StartIndex":0,"TotalAvailable":-1,"MediaItems":[{"Flags":8,"ID":"53ff82a76e11d4772a7647f665a10017","GroupName":"Artists","Title":"Luft Baloons","Type":0,"ArtworkRatio":0,"Duration":0,"BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":-1,"DisplayInfo":["Luft Baloons"]},{"Flags":8,"ID":"fb1a08c2684245786c3b0172d8d93282","GroupName":"Albums","Title":"Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/7cb7e4ce3b885e9b3fceb98cfa0c9da9498c1931","ArtworkRatio":0,"Duration":0,"BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":-1,"DisplayInfo":["Baloons"]},{"Flags":8,"ID":"38194c3f78e5c5f4afe48cc3b6602b2f","GroupName":"Albums","Title":"Cosmic Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/07ccd5b726fcbd404d09fea10e35c6c4b0971125","ArtworkRatio":0,"Duration":0,"BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":-1,"DisplayInfo":["Cosmic Baloons"]},{"Flags":8,"ID":"c706926b1e4c17533af89dc3a90ff4be","GroupName":"Albums","Title":"Hot Air Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/430e51d3ddac573f344cee47994436299eda8cad","ArtworkRatio":0,"Duration":0,"BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":-1,"DisplayInfo":["Hot Air Baloons"]},{"Flags":8,"ID":"a505e9efb3efedd4a9c007d8458c4cb1","GroupName":"Albums","Title":"Volleyball & Baloons (Radio Edit)","Type":0,"ArtworkURI":"http://i.scdn.co/image/0cdc646c7d8c48de26f583e9f7830e996966ff73","ArtworkRatio":0,"Duration":0,"BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":-1,"DisplayInfo":["Volleyball & Baloons (Radio Edit)"]},{"Flags":8,"ID":"3d1be5eecfbd2ee93d6c360bbb6608c3","GroupName":"Albums","Title":"99 Red Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/b54b3bd8cc11dce96efafb89dbaec7a76e7522df","ArtworkRatio":0,"Duration":0,"BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":-1,"DisplayInfo":["99 Red Baloons"]},{"Flags":12289,"ID":"028af25d3eb5f9ac896f9a3bea23f2ad","GroupName":"Tracks","Title":"99 Red Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/7bd7835712e46982773dcb7d723195b901c47c9b","ArtworkRatio":0,"Album":"Lo Mejor de los 80: Los 40 Principales Éxitos de la Música Internacional. Cuarenta Canciones Pop Rock y Disco Años Ochenta","Artists":"Glams","Duration":233.453,"Track":"31","BitRate":0,"ListenerCount":0,"Rating":29,"TotalItems":0,"DisplayInfo":["99 Red Baloons","Glams - Lo Mejor de los 80: Los 40 Principales Éxitos de la Música Internacional. Cuarenta Canciones Pop Rock y Disco Años Ochenta"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:1g2ps9yw7jidMs68N53ZKV"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:2wSlmZan7wna02bl9wRIFu"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:51jECxPnXMcqNGXLCa6szp"}]},{"Flags":12289,"ID":"ed2ae950136d749429509da30238a0f3","GroupName":"Tracks","Title":"Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/7cb7e4ce3b885e9b3fceb98cfa0c9da9498c1931","ArtworkRatio":0,"Album":"Baloons","Artists":"Preen","Duration":170.057,"Track":"1","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Baloons","Preen - Baloons"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:2vAk1Ze1pp8Z8QrAN7HJLq"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:1vkVRCFe1bw8JxKGPj66oX"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:0vp8sBXk7yMfpKxAQW6ntS"}]},{"Flags":12289,"ID":"6a56f790ff6f9b0dfa1a2ff462bd0bbb","GroupName":"Tracks","Title":"Cosmic Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/07ccd5b726fcbd404d09fea10e35c6c4b0971125","ArtworkRatio":0,"Album":"Cosmic Baloons","Artists":"Alvin & The Chipsets","Duration":219.892,"Track":"2","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Cosmic Baloons","Alvin & The Chipsets - Cosmic Baloons"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:0guFwIWQ4unTtPr1ziHXm3"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:50xr4k5eLvQjS1K8hiTG8u"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:3nkQwlMNCN7rpXwdLGIMss"}]},{"Flags":12289,"ID":"dac5cfad118037b47c8afc6b5c8ae2e2","GroupName":"Tracks","Title":"Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/98c78fdfee8986eecc4da6fc6c59b610c1134073","ArtworkRatio":0,"Album":"On a Sunny Day","Artists":"Alessandro Galati Trio","Duration":318.52,"Track":"1","BitRate":0,"ListenerCount":0,"Rating":1,"TotalItems":0,"DisplayInfo":["Baloons","Alessandro Galati Trio - On a Sunny Day"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:5KLGSNY4lzte4eLWn8ocE5"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:68JBLWUNWSwi2hKV4sHNdb"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:7CbEP46niMjldZ5x7OandS"}]},{"Flags":12289,"ID":"2d286bcc3b766c91a3b5283fa30a6e8c","GroupName":"Tracks","Title":"Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/c4b90786783ff5adf5a30245d0a188639098d4d8","ArtworkRatio":0,"Album":"works around tragedies","Artists":"Vadi","Duration":111.54,"Track":"3","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Baloons","Vadi - works around tragedies"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:1zipvFWF0IKY6vIUFbZaEE"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:7rNc4jx1AdBFfIJyB9g4Eh"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:5QHCaNahtPmFTWnZnZXpeO"}]},{"Flags":12289,"ID":"7dda72d4a60e0feb2276f0209d287438","GroupName":"Tracks","Title":"99 Luft Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/f125f82627ce13f3fc77f3faaa7fd33bd55f99e7","ArtworkRatio":0,"Album":"Music For Bondage Clubs","Artists":"Gothic Slut, Inc.","Duration":241.133,"Track":"8","BitRate":0,"ListenerCount":0,"Rating":5,"TotalItems":0,"DisplayInfo":["99 Luft Baloons","Gothic Slut, Inc. - Music For Bondage Clubs"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:0ZmUleHKXGNNjMgbhoL9gL"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:5LdbSUKF3wEdIOqF7XyKUL"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:67fpSHC5T8lkadzpiVDhEK"}]},{"Flags":12289,"ID":"5af1ff31a40e914bb661c728cb248868","GroupName":"Tracks","Title":"Arrows And Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/6560afc892c359bdc336b5bee04894c06efa0cc8","ArtworkRatio":0,"Album":"Moses On A Snail","Artists":"Robert Pollard","Duration":147.906,"Track":"3","BitRate":0,"ListenerCount":0,"Rating":3,"TotalItems":0,"DisplayInfo":["Arrows And Baloons","Robert Pollard - Moses On A Snail"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:4ssWuTb62OICwUqszfG6jl"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:0L8gNE8U7v7YvefZenVKo5"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:3oLblJYzFOq8hmbs529A5B"}]},{"Flags":12289,"ID":"2705ca43d739e17dd0bcfc98802a2fd6","GroupName":"Tracks","Title":"99 Red Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/aa310852ab05cd64af584c1f93d8e3e67868e8b8","ArtworkRatio":0,"Album":"Big 80's Hits of Glam Rock","Artists":"Glams","Duration":233.453,"Track":"4","BitRate":0,"ListenerCount":0,"Rating":7,"TotalItems":0,"DisplayInfo":["99 Red Baloons","Glams - Big 80's Hits of Glam Rock"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:4X7u09dPnPLS1PmTSvJsGe"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:2wSlmZan7wna02bl9wRIFu"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:7BjsJLwGD84oXhn96GjooT"}]},{"Flags":12289,"ID":"2fb0aab18a4cbf99c573354754c287dd","GroupName":"Tracks","Title":"Volleyball & Baloons - Radio Edit","Type":0,"ArtworkURI":"http://i.scdn.co/image/0cdc646c7d8c48de26f583e9f7830e996966ff73","ArtworkRatio":0,"Album":"Volleyball & Baloons (Radio Edit)","Artists":"DJ Adamus","Duration":174.375,"Track":"1","BitRate":0,"ListenerCount":0,"Rating":1,"TotalItems":0,"DisplayInfo":["Volleyball & Baloons - Radio Edit","DJ Adamus - Volleyball & Baloons (Radio Edit)"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:68WkKmTN4U1XJAkG9BNKiE"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:0Db5Yl5ZBHvcqbH3KfCZAt"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:4omp6BLA3IV5tztbQUZZut"}]},{"Flags":12289,"ID":"a256098c833c55e78a903fd0d4b06b32","GroupName":"Tracks","Title":"Crystal Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/94f42c29a076d984d22ed04ad192aff4a501c004","ArtworkRatio":0,"Album":"Burning Electro Beats","Artists":"Red Skin Noxe","Duration":218.712,"Track":"3","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Crystal Baloons","Red Skin Noxe - Burning Electro Beats"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:3qrIYU47adXzmEQjFOdoAc"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:5pCOlq7TQv8x18aqD7CcvK"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:6BXnnLY16uq2Q3LCuDvpvj"}]},{"Flags":12289,"ID":"deb933fe841a8d06008c50a58bcd0330","GroupName":"Tracks","Title":"Crystal Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/19c7b8c6f71154a4e36aead91bcba7f1f54d394a","ArtworkRatio":0,"Album":"Electro Industrial, Vol. 2","Artists":"Red Skin Noxe","Duration":219.293,"Track":"8","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Crystal Baloons","Red Skin Noxe - Electro Industrial, Vol. 2"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:2UlnogkBrl3am6Oh35EKx4"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:5pCOlq7TQv8x18aqD7CcvK"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:7LmhanTMmcyA5cil2x8zdT"}]},{"Flags":12289,"ID":"9609e4150b1039780bd04103a98bbc32","GroupName":"Tracks","Title":"Blue Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/29b73752da2bc7611ceafcec420441a3de9ab2ee","ArtworkRatio":0,"Album":"But Not In SIlence","Artists":"NelCaso","Duration":164.763,"Track":"3","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Blue Baloons","NelCaso - But Not In SIlence"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:0HOGZPSOFMGC1lahWcsCru"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:5TKflmQlVj2cPRDDQ28lG8"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:26IvfPukSEhgeoYXszaOj6"}]},{"Flags":12289,"ID":"4f63016776ffab2d9647a0962ec48d32","GroupName":"Tracks","Title":"Silver Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/5e129fb8dea40623ce7b11696a57650ed7a121c9","ArtworkRatio":0,"Album":"A Walk Into The Sea: Original Soundtrack","Artists":"T. Griffin","Duration":143.133,"Track":"12","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Silver Baloons","T. Griffin - A Walk Into The Sea: Original Soundtrack"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:0Iolq6d8l7oHeiraJKo7PR"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:0aj5eJien0JknsEFo4zRzQ"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:46vLTCAjF4nKLmQGLum6p2"}]},{"Flags":12289,"ID":"271eac68f81c344bb766534c6ed5466f","GroupName":"Tracks","Title":"Blue Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/3291dd7fdf7ae7edc161244dbb80b0383e4947af","ArtworkRatio":0,"Album":"A Honeymoon Too Soon","Artists":"Thomas Hass","Duration":379.253,"Track":"6","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Blue Baloons","Thomas Hass - A Honeymoon Too Soon"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:2OzDRRhEsG5jwBjoYSFn8V"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:4FJQT7ITqdruBkz52CdPcw"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:2WdX8n2YadMZXaG1ZdzURr"}]},{"Flags":12289,"ID":"dfd96e45b3c981766ce037386660b45c","GroupName":"Tracks","Title":"Birthday Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/951109cfcaf49e1bd24b227faf7e2f6d7d3fdecf","ArtworkRatio":0,"Album":"The Daddy Show Chronicles","Artists":"The Daddy Show","Duration":85.394,"Track":"4","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Birthday Baloons","The Daddy Show - The Daddy Show Chronicles"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:1TTnNupYnopNZBokVvL48q"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:2VyLkkzZtBrDnlf29j0woB"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:1kPMDucdXvwpOZp8Gy1rZ7"}]},{"Flags":12289,"ID":"1755274d9c7f3b62d7bc121cef23424a","GroupName":"Tracks","Title":"Blue Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/5725262cae41f724df380de913c5620d41b91d7c","ArtworkRatio":0,"Album":"A Honeymoon Too Soon","Artists":"Thomas Hass","Duration":379.253,"Track":"6","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Blue Baloons","Thomas Hass - A Honeymoon Too Soon"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:3vBVS9ovQZZtW8yuJyBYoz"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:4FJQT7ITqdruBkz52CdPcw"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:4mvwFPlCY4nppkmzSGqv1R"}]},{"Flags":12289,"ID":"8fbcc5dd099b25cd4a1f20450def23c6","GroupName":"Tracks","Title":"Crystal Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/ea8613bda940ecd0681f85c52d4f073b8db98aa8","ArtworkRatio":0,"Album":"Thunder Beat: Ultimate Beats & Breaks Dance Selection","Artists":"Red Skin Noxe","Duration":219.338,"Track":"15","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Crystal Baloons","Red Skin Noxe - Thunder Beat: Ultimate Beats & Breaks Dance Selection"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:31F7T8XY8HozJJ8kuVOISW"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:5pCOlq7TQv8x18aqD7CcvK"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:601ubfXbazC9Udx9q86dTN"}]},{"Flags":12289,"ID":"97dffac7319cae541443aa36c5334feb","GroupName":"Tracks","Title":"Back From Saturn","Type":0,"ArtworkURI":"http://i.scdn.co/image/07ccd5b726fcbd404d09fea10e35c6c4b0971125","ArtworkRatio":0,"Album":"Cosmic Baloons","Artists":"Alvin & The Chipsets","Duration":221.988,"Track":"1","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Back From Saturn","Alvin & The Chipsets - Cosmic Baloons"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:0guFwIWQ4unTtPr1ziHXm3"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:50xr4k5eLvQjS1K8hiTG8u"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:62a6eezOrMCBJ6VrQXNnav"}]},{"Flags":12289,"ID":"5175791546e49a7f21df14efad1e5525","GroupName":"Tracks","Title":"Eldorado","Type":0,"ArtworkURI":"http://i.scdn.co/image/07ccd5b726fcbd404d09fea10e35c6c4b0971125","ArtworkRatio":0,"Album":"Cosmic Baloons","Artists":"Alvin & The Chipsets","Duration":227.752,"Track":"3","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["Eldorado","Alvin & The Chipsets - Cosmic Baloons"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:0guFwIWQ4unTtPr1ziHXm3"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:50xr4k5eLvQjS1K8hiTG8u"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:3PzYZ1CdKis7MVfpdgQKMo"}]},{"Flags":12289,"ID":"1a3eb2ea8803ad377172b70d0d8f9726","GroupName":"Tracks","Title":"13 Green Baloons","Type":0,"ArtworkURI":"http://i.scdn.co/image/560c56e88270d4f0e985479b6b7f751ed762dd6c","ArtworkRatio":0,"Album":"Selective: House, Vol. 3","Artists":"Mike Dokos","Duration":253.548,"Track":"20","BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":0,"DisplayInfo":["13 Green Baloons","Mike Dokos - Selective: House, Vol. 3"],"ContextMenuItems":[{"Type":1,"Title":"Go to Album","Value":"spotify4:album:846df04b-59c4-4289-83fc-28267ed59cfb:3hy6mwveQSzoggItd74jDk"},{"Type":1,"Title":"Go to Artist","Value":"spotify4:artist:846df04b-59c4-4289-83fc-28267ed59cfb:2zwkY6VC8SFNYV3FiTP0zB"},{"Type":1,"Title":"More Like This","Value":"spotify4:rec:846df04b-59c4-4289-83fc-28267ed59cfb:65quJMMiwcln3dGZlVpFA7"}]},{"Flags":8,"ID":"51cfb94fdd532bbf233a593687b9f2a4","GroupName":"Tracks","Title":"More results...","Type":0,"ArtworkRatio":0,"Duration":0,"BitRate":0,"ListenerCount":0,"Rating":0,"TotalItems":-1,"DisplayInfo":["More results..."]}]}`,
status: http.StatusOK,
}
}
func (msh *mediaSearchMCHandler) handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(msh.status)
w.Write([]byte(msh.response))
}
// casatunes.MediaSearchMC should return object casatunes.RESTMediaCollectionItem
// from casaplayerEndpoint
func TestMediaSearchMC(t *testing.T) {
once.Do(startServer)
casaplayerEndpoint := "http://" + serverAddr + "/"
media_collection := "01234567890" // Spotify internet radio
search_text := "baloons"
msmc := newMediaSearchMCHandler()
http.HandleFunc(
"/media/search/" + media_collection + "/" + search_text,
func(w http.ResponseWriter, r *http.Request) { msmc.handler(w, r) },
)
t.Run("Valid object returned", func(t *testing.T) {
client := New(casaplayerEndpoint)
resp, err := client.MediaSearchMC(media_collection, search_text)
if err != nil {
t.Fatal(err)
}
if reflect.TypeOf(resp) != reflect.TypeOf(&RESTMediaCollectionItem{}) {
t.Fatal("MediaSearchMC did not return object of type casatunes.RESTMediaCollectionItem !")
} else {
t.Log("MediaSearchMC returned casatunes.RESTMediaCollectionItem object")
}
})
t.Run("Pull the title of the first song", func(t *testing.T) {
client := New(casaplayerEndpoint)
resp, err := client.MediaSearchMC(media_collection, search_text)
if err != nil {
t.Fatal(err)
}
if resp.MediaItems[0].Title != "Luft Baloons" {
t.Fatal("Title of first MediaItem is not 'Luft Baloons'")
} else {
t.Log("Found 'Luft Baloons' as first MediaItem")
}
})
t.Run("Nonexistant endpoint", func(t *testing.T) {
client := New("http://unresolvable:456")
_, err := client.MediaSearchMC(media_collection, search_text)
if err != nil {
t.Log("Received error on nonexistant endpoint")
} else {
t.Fatal("No error received on nonexistant endpoint !")
}
})
t.Run("Invalid URI", func(t *testing.T) {
client := New("GarbageText")
_, err := client.MediaSearchMC(media_collection, search_text)
if err != nil {
t.Log("Invalid URI rejected.")
} else {
t.Fatal("MediaSearchMC accepted casatunes.Client with bad URI !")
}
})
t.Run("HTTP 503 Response Code", func(t *testing.T) {
client := New(casaplayerEndpoint)
msmc.status = http.StatusServiceUnavailable
_, err := client.MediaSearchMC(media_collection, search_text)
if err != nil {
t.Log("[503] Error received.")
} else {
t.Fatal(err)
}
})
}