-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsearch_test.go
40 lines (36 loc) · 1.11 KB
/
search_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
package subsonic
import "testing"
func runSearchTests(client Client, t *testing.T) {
sampleArtist := getSampleArtist(client)
t.Run("Search2", func(t *testing.T) {
results, err := client.Search2(sampleArtist.Name, nil)
if err != nil {
t.Error(err)
}
// The non-id3 matching does not consistently return an artist, but it does erturn that artist's albums
if len(results.Album) == 0 {
t.Errorf("Could not find any albums for a known artist %s", sampleArtist.Name)
}
})
t.Run("Search3", func(t *testing.T) {
results, err := client.Search3(sampleArtist.Name, nil)
if err != nil {
t.Error(err)
}
if len(results.Artist) == 0 {
t.Errorf("Could not find a known artist %s", sampleArtist.Name)
}
returnOneArtist := map[string]string{
"artistCount": "1",
"songCount": "0",
"albumCount": "0",
}
results, err = client.Search3(sampleArtist.Name, returnOneArtist)
if err != nil {
t.Error(err)
}
if len(results.Artist) != 1 || len(results.Song) != 0 || len(results.Album) != 0 {
t.Errorf("Improperly limited results of search for %s: %#v", sampleArtist.Name, results)
}
})
}