forked from kkdai/youtube
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyoutube_test.go
More file actions
52 lines (42 loc) · 1017 Bytes
/
youtube_test.go
File metadata and controls
52 lines (42 loc) · 1017 Bytes
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
package youtube
import (
"os/user"
"path/filepath"
"testing"
)
const dwlURL string = "https://www.youtube.com/watch?v=rFejpH_tAHM"
const priURL string = "https://www.youtube.com/watch?v=FHpvI8oGsuQ"
const errURL string = "https://www.youtube.com/watch?v=I8oGsuQ"
var dfPath string
func TestMain(m *testing.M) {
//init download path
usr, _ := user.Current()
dfPath = filepath.Join(usr.HomeDir, "Movies", "test")
m.Run()
}
func TestDownloadFirst(t *testing.T) {
y := NewYoutube(false)
if y == nil {
t.Error("Cannot init object.")
return
}
if err := y.StartDownload(dfPath); err == nil {
t.Error("No video URL input should not download.")
return
}
}
func TestParseVideo(t *testing.T) {
y := NewYoutube(false)
if y == nil {
t.Error("Cannot init object.")
return
}
if err := y.DecodeURL(dwlURL); err != nil {
t.Error("This video parsing should work well.")
return
}
if err := y.DecodeURL(errURL); err == nil {
t.Error("This video parsing should not work well.")
return
}
}