-
Notifications
You must be signed in to change notification settings - Fork 13
/
playlist_test.go
69 lines (64 loc) · 1.51 KB
/
playlist_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
package subsonic
import (
"fmt"
"testing"
"time"
)
func runPlaylistTests(client Client, t *testing.T) {
t.Run("GetPlaylists", func(t *testing.T) {
playlists, err := client.GetPlaylists(nil)
if err != nil {
t.Error(err)
}
var empty time.Time
for _, p := range playlists {
if p.ID == "" {
t.Errorf("Invalid playlist returned %#v", p)
}
if p.Created == empty {
t.Errorf("Playlist %#v had an empty created", p)
}
}
})
// State-heavy test for playlist CRUD
testPlaylistName := fmt.Sprintf("Test playlist %v", time.Now().Unix())
t.Run("CreatePlaylist", func(t *testing.T) {
err := client.CreatePlaylist(map[string]string{
"name": testPlaylistName,
})
if err != nil {
t.Error(err)
}
})
testPlaylist, err := findPlaylistByName(client, testPlaylistName)
if err != nil {
t.Log(err)
}
t.Run("GetPlaylist", func(t *testing.T) {
playlist, err := client.GetPlaylist(testPlaylist.ID)
if err != nil {
t.Error(err)
}
if playlist.ID == "" || playlist.ID != testPlaylist.ID {
t.Errorf("Invalid playlist returned %#v", playlist)
}
var empty time.Time
if playlist.Created == empty {
t.Errorf("Playlist %#v had an empty created", playlist)
}
})
t.Run("UpdatePlaylist", func(t *testing.T) {
err = client.UpdatePlaylist(testPlaylist.ID, map[string]string{
"comment": "Whee there buddy",
})
if err != nil {
t.Error(err)
}
})
t.Run("DeletePlaylist", func(t *testing.T) {
err = client.DeletePlaylist(testPlaylist.ID)
if err != nil {
t.Error(err)
}
})
}