-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_test.go
59 lines (53 loc) · 1.44 KB
/
client_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
package soundcloader
import (
"log"
"os"
"testing"
)
func Test_Get(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
wantErr bool
}{
{"Song", args{s: "https://soundcloud.com/unitasprima/yasuha-flyday-chinatown"}, false},
{"Song from playlist", args{s: "https://soundcloud.com/iamtrevordaniel/falling?in=iamtrevordaniel/sets/homesick"}, false},
{"Station", args{s: "https://soundcloud.com/stations/track/unitasprima/yasuha-flyday-chinatown"}, true},
{"Playlist", args{s: "https://soundcloud.com/discover/sets/charts-top:all-music:ua"}, true},
{"Playlist #2", args{s: "https://soundcloud.com/nitza-md/sets/piano-deep-concentration"}, true},
{"User", args{s: "https://soundcloud.com/faceless1-7"}, true},
{"song with some text", args{"Check this: https://soundcloud.com/unitasprima/yasuha-flyday-chinatown"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cl := DefaultClient
//cl.SetDebug(true)
var filename string
result, err := cl.Get(tt.args.s)
if err == nil {
filename, err = result.GetNext()
}
if err != nil || result == nil {
if tt.wantErr {
return
}
log.Print(err)
t.Fail()
return
}
log.Print(result.Thumbnail)
if _, err := os.Stat(filename); err != nil {
t.Fail()
}
})
}
}
// just to make sure gofmt wont throw errors
func _() {
_, _ = Get("")
_, _ = GetURL(nil)
_ = ParseURL(nil)
}