-
Notifications
You must be signed in to change notification settings - Fork 14
/
annotation_test.go
85 lines (79 loc) · 1.81 KB
/
annotation_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
package subsonic
import (
"fmt"
"testing"
"time"
)
func runAnnotationTests(client Client, t *testing.T) {
sampleArtist := getSampleArtist(client)
sampleSong := getSampleSong(client)
sampleAlbum := getSampleAlbum(client)
itemsToStar := StarParameters{
SongIDs: []string{sampleSong.ID},
AlbumIDs: []string{sampleAlbum.ID},
ArtistIDs: []string{sampleArtist.ID},
}
t.Run("Star", func(t *testing.T) {
err := client.Star(itemsToStar)
if err != nil {
t.Error(err)
}
})
t.Run("Unstar", func(t *testing.T) {
err := client.Unstar(itemsToStar)
if err != nil {
t.Error(err)
}
})
t.Run("SetRating", func(t *testing.T) {
err := client.SetRating(sampleSong.ID, -1)
if err == nil {
t.Error("Bounds checking on ratings failed")
}
err = client.SetRating(sampleSong.ID, 10)
if err == nil {
t.Error("Bounds checking on ratings failed")
}
err = client.SetRating(sampleSong.ID, 4)
if err != nil {
t.Error(err)
}
err = client.SetRating(sampleSong.ID, 0)
if err != nil {
t.Error(err)
}
err = client.SetRating(sampleArtist.ID, 5)
if err != nil {
t.Error(err)
}
err = client.SetRating(sampleArtist.ID, 0)
if err != nil {
t.Error(err)
}
})
t.Run("Scrobble", func(t *testing.T) {
err := client.Scrobble(sampleSong.ID, map[string]string{
"time": "not-an-int",
})
if err == nil {
t.Error("Typecheck on time argument failed")
}
err = client.Scrobble(sampleSong.ID, map[string]string{
"submission": "not-a-bool",
})
if err == nil {
t.Error("Typecheck on submission argument failed")
}
err = client.Scrobble(sampleSong.ID, map[string]string{
"time": fmt.Sprintf("%d", time.Now().Unix()),
"submission": "true",
})
if err != nil {
t.Error(err)
}
err = client.Scrobble(sampleSong.ID, nil)
if err != nil {
t.Error(err)
}
})
}