-
Notifications
You must be signed in to change notification settings - Fork 298
/
track_test.go
72 lines (62 loc) · 1.74 KB
/
track_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
package spotify
import (
"context"
"net/http"
"testing"
)
func TestFindTrack(t *testing.T) {
client, server := testClientFile(http.StatusOK, "test_data/find_track.txt")
defer server.Close()
track, err := client.GetTrack(context.Background(), "1zHlj4dQ8ZAtrayhuDDmkY")
if err != nil {
t.Error(err)
return
}
if track.Name != "Timber" {
t.Errorf("Wanted track Timer, got %s\n", track.Name)
}
}
func TestFindTrackWithFloats(t *testing.T) {
client, server := testClientFile(http.StatusOK, "test_data/find_track_with_floats.txt")
defer server.Close()
track, err := client.GetTrack(context.Background(), "1zHlj4dQ8ZAtrayhuDDmkY")
if err != nil {
t.Error(err)
return
}
if track.Name != "Timber" {
t.Errorf("Wanted track Timer, got %s\n", track.Name)
}
}
func TestFindTracksSimple(t *testing.T) {
client, server := testClientFile(http.StatusOK, "test_data/find_tracks_simple.txt")
defer server.Close()
tracks, err := client.GetTracks(context.Background(), []ID{"0eGsygTp906u18L0Oimnem", "1lDWb6b6ieDQ2xT7ewTC3G"})
if err != nil {
t.Error(err)
return
}
if l := len(tracks); l != 2 {
t.Errorf("Wanted 2 tracks, got %d\n", l)
return
}
}
func TestFindTracksNotFound(t *testing.T) {
client, server := testClientFile(http.StatusOK, "test_data/find_tracks_notfound.txt")
defer server.Close()
tracks, err := client.GetTracks(context.Background(), []ID{"0eGsygTp906u18L0Oimnem", "1lDWb6b6iecccdsdckTC3G"})
if err != nil {
t.Error(err)
return
}
if l := len(tracks); l != 2 {
t.Errorf("Expected 2 results, got %d\n", l)
return
}
if tracks[0].Name != "Mr. Brightside" {
t.Errorf("Expected Mr. Brightside, got %s\n", tracks[0].Name)
}
if tracks[1] != nil {
t.Error("Expected nil track (invalid ID) but got valid track")
}
}