-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrapidvideo_test.go
102 lines (79 loc) · 2.01 KB
/
rapidvideo_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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package rapidvideo
import (
"testing"
"os"
)
func NewTestRapidVideo() (rv Rapidvideo){
var userId = os.Getenv("RAPID_VIDEO_USER_ID")
var apiKey = os.Getenv("RAPID_VIDEO_API_KEY")
return NewRapidVideo(userId, apiKey)
}
func TestCreateRapidVideo(t *testing.T){
var userId = os.Getenv("RAPID_VIDEO_USER_ID")
var apiKey = os.Getenv("RAPID_VIDEO_API_KEY")
var rv Rapidvideo
if userId == "" {
t.Error("RAPID_VIDEO_USER_ID is not defined")
}
if apiKey == "" {
t.Error("RAPID_VIDEO_API_KEY is not defined")
}
rv = NewTestRapidVideo()
if rv == nil {
t.Error("Error creating Rapidvideo")
}
_, ok := rv.(*rapidvideo)
if ok == false {
t.Error("Could not switch Rapidvideo interface to rapidvideo struct")
}
}
func TestSetProxy(t *testing.T){
var rv Rapidvideo = NewTestRapidVideo()
var err error
err = rv.SetProxy("socks5://127.0.0.1:9050")
if err != nil {
t.Error("Error setting a proxy:", err)
}
}
func TestGetInfo(t *testing.T) {
var rv Rapidvideo = NewTestRapidVideo()
v, err := rv.GetInfo("code")
if err != nil {
t.Error("Error upload a file", err.Error())
}
if v == nil {
t.Error("Empty video code")
}
}
func TestUpload(t *testing.T) {
var rv Rapidvideo = NewTestRapidVideo()
var err error
err = rv.Upload("")
if err == nil {
t.Error("Should raise an error for invalid file path")
}
err = rv.Upload("")
if err != nil {
t.Error("Error upload a file", err.Error())
}
}
func TestRemoteUpload(t *testing.T) {
var rv Rapidvideo = NewTestRapidVideo()
ok, err := rv.RemoteUpload("url")
if err != nil {
t.Error("Error creating a remote file upload", err.Error())
}
if ok != true {
t.Error("Should create a remote upload")
}
}
func TestRemoteStatus(t *testing.T) {
var rv Rapidvideo = NewTestRapidVideo()
status, err := rv.RemoteStatus("id")
if err == nil {
t.Error("Should raise an error for invalid object id")
}
if status != nil {
t.Error("Should have a nil status for invalid object id")
}
}